权重python错误语法错误

权重python错误语法错误,python,input,syntax-error,user-input,Python,Input,Syntax Error,User Input,我再次回顾Python,我来到了这个早期阶段,再次陷入困境。 我需要: 用Python编写一个程序,要求用户提供 名称和“重量”,单位为千克。然后该程序将 输出一个句子,告知用户他们的体重(以克和磅为单位) 这是我的代码: myName = str(input('What is your name?:')) myWeight = int(input( myName+ 'What is your weight in kilograms?:') weightGrams = 'myWeight*1

我再次回顾Python,我来到了这个早期阶段,再次陷入困境。 我需要:

用Python编写一个程序,要求用户提供
名称和“重量”,单位为千克。然后该程序将
输出一个句子,告知用户他们的体重(以克和磅为单位)

这是我的代码:

myName = str(input('What is your name?:'))

myWeight = int(input( myName+ 'What is your weight in kilograms?:')

weightGrams = 'myWeight*1000'
weightPounds = 'myWeight*2.2'



print(myName+ 'You would weigh', weightGrams, 'in grams and' weightPounds, 'in pounds!')
我没有得到正确的输出,而且我得到了语法错误。 SyntaxErrors如下所示:

weightGrams = 'myWeight*1000'
weightPounds = 'myWeight*2.2'
最后:

print(myName+ 'You would weigh', weightGrams, 'in grams and' weightPounds, 'in pounds!')

如何修复这些问题?

不要将
int
视为
string

weightGrams = myWeight*1000
weightPounds = myWeight*2.2
myName = input('What is your name?:')
您的
打印文件中也有语法错误

print(myName+ ' You would weigh', weightGrams, 'in grams and', weightPounds, 'in pounds!')
此外,您不需要在此处强制转换为
str
,因为
input
已经发出了一个
string

weightGrams = myWeight*1000
weightPounds = myWeight*2.2
myName = input('What is your name?:')
最终编辑:您缺少一个结束括号
此处:

myWeight = int(input( myName+ 'What is your weight in kilograms?:'))

我试过了,但结果是无效的语法等等,让我再试一次,没有看到顶部的部分被编辑并修复了你的语法错误,我一直收到语法错误..?哦,我收到了,哈哈,谢谢,老兄,谢谢