Him*_*AVA 6 python python-idle
我怎么写
>>> x = int(raw_input("Please enter an integer: "))
>>> if x < 0:
... x = 0
... print 'Negative changed to zero'
... elif x == 0:
... print 'Zero'
... elif x == 1:
... print 'Single'
... else:
... print 'More'
...
Run Code Online (Sandbox Code Playgroud)
在IDLE.一旦我写完第一行后按Enter键,它就会执行第一行,我无法编写完整的代码.我是python的新手,今天就开始了.任何帮助将不胜感激.
1:在第
2 行之间使用分号:尝试iPython
3:将其写为函数,例如
def myfunc():
x = int(raw_input("Please enter an integer: "))
if x < 0:
x = 0
print 'Negative changed to zero'
elif x == 0:print 'Zero'
elif x == 1:print 'Single'
else:print 'More'
Run Code Online (Sandbox Code Playgroud)