我完全是编程的新手,我一直在试图获得一段简单的代码。不过,我不断收到多个不同的错误,所以我认为我做的东西沿线某处非常错误...这里是我的代码的时刻:如果语句条件不符合,返回到一段代码的开头
userName = input('Please enter your name: ')
age = input('Please enter your age: ')
if int(age) <= 5:
print(userName, 'you are too young to play') break
else:
print (userName, 'Your old enough')
factor = 2
finalAge = int(age) + int(factor)
multAge = int(age) * int(factor)
divAge = float(age)/int(factor)
print('In', factor, 'years you will be', finalAge, 'years old', userName)
print('Your age multiplied by', factor, 'is', multAge)
print('Your age divided by', factor, 'is', divAge)
我想要做的是,如果用户的年龄不会高于5,那么他们会收到这样的信息,即他们太年轻了,无法播放,并返回到代码片段的开头 - 再次请求该名称。
有没有人有任何建议如何做到这一点?