Python noob我需要循环帮助

时间:2017-07-15 04:02:14

标签: python loops

导入时间

print ('Hi!')
time.sleep(1)
print('my name is Magiting')
time.sleep(1)
myname = "Magiting"
realname = 'Uldarico'
while true:
        name = str(input("What's yours? "))
if name == myname:
 print("Nope, that's my name")
 print("Try again")
elif name == realname:
 print ('I dont want to do this, SPY!')
 print ('line disconnected...')
break
else:
 print (name+ "? That's quite a unique name")
 print ('...')

time.sleep(1)
print ('So, '+ name + ', what can I do for you?')

这是我的代码,我一次又一次地改变它,但我似乎无法将第一个语句循环到输入,第二个语句在第三个语句中继续进行,而第三个语句继续。

1 个答案:

答案 0 :(得分:0)

import time
print ('Hi!')
time.sleep(1)
print('my name is Magiting')
time.sleep(1)
myname = "Magiting"
realname = 'Uldarico'
while True:
    name = raw_input("What's yours? ")
    if name == myname:
        print("Nope, that's my name")
        print("Try again")
    elif name == realname:
        print ('I dont want to do this, SPY!')
        print ('line disconnected...')
        break
    else:
        print (name+ "? That's quite a unique name")
        print ('...')

time.sleep(1)
print ('So, '+ name + ', what can I do for you?')