different results in IDLE and Windows console
I write this simple bit of code (Python 3.2 on Win32):
def main():
decision = input('¿Send mail? (y/n): ')
if decision == "y":
sender()
print("Mail sent.")
else:
print("Cancelled.开发者_开发知识库")
input()
def sender():
print("In sender ... ")
pass
main()
and it works as expected in IDLE, but in the Windows console it surprisingly says 'cancelled' when you choose 'y'.
Now this makes no sense to me, Can you please help me see what's wrong?
I suggest you read the definition of input()
. It is not recommended for general user input as it expects syntactically valid Python code and eval()
s it.
精彩评论