我需要確保符合所有條件,並有特殊情況。即使未達到'2010年前'或'gerequirements',學生仍被視爲'符合資格'。y的提示用戶,是,n或否
但是,我無法讓程序正常工作。我希望能夠爲「是/否」問題的答案輸入'y','是','n'或'否',但它會作爲錯誤發佈,因爲我沒有指定'y'顯然。
def main():
credits = int(input("Enter the total number of credits completed: "))
udcredits = int(input("Enter the number of upper-division credits completed: "))
localcredits = int(input("Enter the number of local credits completed: "))
mrequirements = input("Have you completed all major requirements? ")
before2010 = eval(input("In what year did you matriculate? "))
gerequirements = input("Are your general education requirements done? ")
if before2010 < 2010 and credits >= 120 and udcredits >= 40 and localcredits >= 30 and mrequirements[0] == y:
print("eligible")
else:
print("ineligible")
if gerequirements[0] == y and credits >= 120 and udcredits >= 40 and localcredits >= 30 and mrequirements[0] == y:
print("eligible")
else:
print("ineligible")
main()
你使用Python 2嗎? –
也'gerequirements [0] =='你'確保你得到那裏的報價。你可能期待一個字符串。 –
我正在使用python 3.設置撇號讓它運行,現在我只是堅持如何使代碼根據輸入的答案做正確的輸出。 –