语法错误无效

时间:2016-09-22 17:22:31

标签: python syntax

我正在尝试编写一个程序,通过询问一个人的体重(千克)和身高(米)来计算体重指数。为什么我在这里得到无效的语法错误?

units = input("What units would you like to use? Enter I for Imperial or M for Metric")

weight = input(int("what's your weight?")

height = input(int("what's your height?")

enter image description here

3 个答案:

答案 0 :(得分:4)

你选错了订单。您应该 submitData() { var anyChangeDetected: boolean = false; for(var i=0;i<this.subscriptionList.length;i++) { if(this.subscriptionList[i].value != this.subscriptionList[i].initialValue) { anyChangeDetected = true; this.remedyService.submitSubscription(this.subscribeObject).subscribe( data =>{ }, err=>{ }, ()=>{ }); } } if(anyChangeDetected == false) { alert("Data is not changed"); } } 而不是int(input())

而且你的input(int())比你应该少。{1}}。检查每个开口支架是否有关闭

答案 1 :(得分:1)

您的int和输入顺序错误,并且忘记了右括号:

units = input("What units would you like to use? Enter I for Imperial or M
for Metric")

weight = int(input("what's your weight?"))

height = int(input("what's your height?"))

答案 2 :(得分:0)

避免使用input()并使用raw_input()代替。你也把int()放在错误的地方。

您的代码应如下所示:

units = raw_input('What units would you like to use?....')

weight = int(raw_input("what's your weight?"))

height = int(raw_input("what's your height?"))