我只是在练习几行代码,这不是针对任何特定的程序,但是搞砸我的是我希望输入光标出现在打印旁边,但是在同一时间我需要在同一行中定义一个变量,因为e
不能等于4
,所以我将e
定义为无效。这里是我的代码:if-then语句与比较两个变量
a = int(input("Give me a Number: "))
b = int(input("Give me another number: "))
c = b + a
def none():
pass
e = none()
print("the sum of"), a, ("and"), b, ("is"), c
d = int(input("Please Insert your age here: "))
if d < 18:
print("Sorry you must be 18 years or older to enter this site")
else:
print("Welcome to www.example.com")
print("What is 2+2: "), e == int(input("")),
if e == 4:
print("good Job!")
else:
print("sorry no")
而不是'e = none()'你可以做'e = None'。 '=='是'做这两件事平等吗?'运算符,而不是赋值运算符,它是一个'='。 – Patashu 2013-03-28 06:03:51
这里有一个有效的一般问题(来自OP缺乏Python经验),但我似乎无法以任何明智的方式概括原文。投票结果太局部。 – brice 2013-03-29 21:15:28