Apr-20-2019, 03:08 AM
Hello! What I am trying to do, is the following:
This program opens a file, where it is supposed to read lines of data (Which right now it does fine, in correct order), and validate the name, to ensure that line where the name would be is not empty. However, when I try to validate it, it essentially ignores my validation and proceeds like it's not even there. How can I get it to work?
Thanks in advance!
This program opens a file, where it is supposed to read lines of data (Which right now it does fine, in correct order), and validate the name, to ensure that line where the name would be is not empty. However, when I try to validate it, it essentially ignores my validation and proceeds like it's not even there. How can I get it to work?
Thanks in advance!
def welcome(): print("Welcome to Academic Helper 2,0.") print("This program determines the grade you would get or the number of hours you need to study") def doAnOption(): enterAnOption = input("\nPlease enter A if you would like to find out number of hours you would need to study for the grade you want\n\nPlease enter B if you would like to find out the grade you would get based on number of hours you are studying per week\n") if enterAnOption.upper() == "A": optionA() elif enterAnOption.upper() == "B": optionB() def optionA(): studHours = open("StudyHours.txt", "r") name = str(studHours.readline()) while name != "": validateName(name) creditHours = studHours.readline() grade = studHours.readline() print(name, creditHours, grade,) name = studHours.readline() def validateName(name): while name == "": name = input("Name can not be empty, please enter proper name") def gradeStudyWeekHours(creditHours): classesTaken = int(creditHours) / 3 print(classesTaken) def optionB(): print("something") welcome() doAnOption()