classification
Title: if sentence doesn't work with input()
Type: Stage:
Components: Interpreter Core Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, kozmof
Priority: normal Keywords:

Created on 2015-12-24 06:58 by kozmof, last changed 2015-12-24 07:02 by benjamin.peterson. This issue is now closed.

Messages (2)
msg256954 - (view) Author: Kozo Oeda (kozmof) Date: 2015-12-24 06:58
if sentence doesn't work well with input() in Python 3(I confirmed 3.4.3 and 3.5.1 on OS X 10.10.5). I also confirmed Python 2.7.11 works well. I think the code which I wrote in the lower section explains what happened enough. 

I couldn't get the proper component so I selected Interpreter Core temporally.
Thanks 

#============Code Start=================
#Python 3.4.3 and 3.5.1 on OS X 10.10.5

def test(a):
	if a == 0:
		print("0")
	else:
		print("not 0")

a = input()
print(a)
test(a)

# Input 
# 0 
#
# Output
# 0
# 0
# not 0

# Input
# 1
#
# Output
# 1
# 1
# not 0
#============Code End=================
msg256955 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-12-24 07:02
In Python 2, input() is basically equivalent to eval(raw_input()). In Python 3, input() is the same as raw_input() in Python 2. This explains the difference.
History
Date User Action Args
2015-12-24 07:02:17benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg256955

resolution: not a bug
2015-12-24 06:58:51kozmofcreate