当你在while循环中输入一个数字值时,循环结束,程序也结束。但是,当我键入“break”时,我得到了一个无效的语法错误:(。对于错误的编码,很抱歉,这是我第一次
print('Hello, world!')
print('What is your name?')
myName = input()
print('It is nice to met you, '+ myName)
print('The length of your name is:')
print(len(myName))
print('What is your age?')
myAge=input()
if myAge.isdigit():print('You will be ' + str(int(myAge) + 1) + ' in "one" year')
else: print('that is not a number. Lets try again, what is your age?')
C = 0
while (C<=3):
myAge2=input()
C+=1
if myAge2.isdigit():print('You will be ' + str(int(myAge2) + 1) + ' in "one" year')
break
else: print('Try again')
我试图简化代码:
代码缩进有问题,否则一切都正常工作
Output
缩进以应用正确的
break
相关问题 更多 >
编程相关推荐