Python 我总是在任何“上”出现语法错误;及;声明
我正在尝试执行uni赋值,但我一直收到无效语法错误,错误出现在“两件事”的第12行:Python 我总是在任何“上”出现语法错误;及;声明,python,Python,我正在尝试执行uni赋值,但我一直收到无效语法错误,错误出现在“两件事”的第12行: 将while条件更改为while weight!=0或weight='end': 将您的体重标准更改为elif 66两件事: 将while条件更改为while weight!=0或weight='end': 将您的体重标准更改为elif 66weight!=0或weight='end':weight>=66和weight-weight='end'将在转换为int时失败。请记住,您是在与计算机交谈,而不是与人
- 将while条件更改为
while weight!=0或weight='end':
- 将您的体重标准更改为
elif 66两件事:
- 将while条件更改为
while weight!=0或weight='end':
- 将您的体重标准更改为
elif 66
weight!=0或weight='end':
weight>=66和weight-weight='end'将在转换为int时失败。请记住,您是在与计算机交谈,而不是与人交谈。计算机不理解“您之前说的‘weight’”的上下文,因此这里暗示了这一点“。每次都需要明确告知它,并且不做任何假设。这个错误不是由打字错误造成的:我们不要因为这个原因投票关闭它。为什么你自己有
和input('fighter name:')
?你的意思是把int(input('fighter weight:'))
fight=input('fighter name:')和
?为什么它们在每个if块中,而不是在循环的末尾?weight=int(input('fighter weight:'))
weight!=0或WEIGHT='end':
WEIGHT>=66和WEIGHT-WEIGHT='end'将在转换为int时失败。请记住,您是在与计算机交谈,而不是与人交谈。计算机不理解“你刚才说‘重量’,所以这里暗示了它”的上下文。它需要在每次转弯时都被明确告知,并且不做这样的假设。这个错误不是由打字错误引起的:我们不投票关闭它。为什么你有
和input('fighter name:')
自己?你的意思是把int(input('fighter weight:'))
fight=input('fighter name:')和
?为什么它们在每个if块中,而不是在循环的末尾?weight=int(input('fighter weight:'))
fight = input('fighter name:') weight = int(input('fighter weight:')) print('given name:{}'.format(fight)) print('given weight:{}'.format(weight)) while weight != 0 or 'end': if weight <= 65: print('{} is of the lightweight category.'.format(fight)) input('fighter name:') int(input('fighter weight:')) elif weight >= 66 and <= 72: print('{} is of the medium weight category.'.format(fight)) input('fighter name:') int(input('fighter weight:')) elif weight >= 73: print('{} is of the heavyweight category.'.format(fight)) input('fighter name:') int(input('fighter weight:')) else: print("invalid weight.") input('fighter name:') int(input('fighter weight:'))
- 将while条件更改为