我找不出來。
到目前爲止,我有,但它不工作,無論我輸入多少年,它告訴我我可以當總統。如何用間隔編寫if語句?
import math
(x) = input("Please enter your name:")
(y) = input("Please enter your age:")
print ("Hello" + x)
print ("Your age is" + y)
if ("y")> ("0") and ("y") < ("18"):
print("You are a minor.")
if ("y")>=("18") and ("y") < ("25"):
print("You can vote.")
if ("y")>= ("25") and ("y") < ("35"):
print("You can rent a car.")
if ("y") >= ("35"):
print("You can be president.")
else:
print ("You have not entered a valid response. Must be a positive integer.")
如何正確獲取間隔?
圓括號裏的東西是否應該是變量?你不需要元組嗎?(我會擺脫括號,因爲這隻會給你添加混淆。) – Makoto 2014-09-06 05:59:21