未使用打印功能定义python变量

时间:2018-08-20 17:48:54

标签: python

运行以下代码后,python提示错误,并告诉我未定义名称“ tony”。

print('Hello Sam, this is Javis')
#let user enter their name, "nm" being the variable
nm = input('Please tell me your name => ')
print('It is definitely nice to meet you',nm,'!')

我输入的名字是“ Tony”

我做错了什么?

1 个答案:

答案 0 :(得分:0)

由于要添加输入,因此需要使用“ +”而不是逗号。像这样:

print('It is definitely nice to meet you '+nm+'!')