'Determening if a list of bachelor courses has a prerequisite or not in python
I have to write a code that determines if a course has a prerequisite or not. In the list at the bottom the 2 courses are mathematics 2, and physics electro magnetics. When I run the code given it says that all the courses have a prerequisite, only the last "none" contains "No prerequisites". I don't understand what I am doing wrong.
fhand = open('ba1.txt')
for i in fhand:
courses = i.split(";")
print(courses[1])
if courses[1] == "none":
print("No prerequisites")
else:
print("There is a prerequisite")
mathematics 1;none
chemistry 1;none
basics of physics;none
geosciences;none
principles of sustainability;none
applied biological sciences;none
introduction to informatics;none
mathematics 2;mathematics 1:end
physics electro magnetics;mathematics 1:end
integrative project;none
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
