world = 'World'
hello_world =hello +''+ World
print(hello_world) # Note: you should print "Hello World"
结果
Traceback (most recent call last):
/PycharmProjects/Introduction to Python/Strings/Concatenation/concatenation.py", line 4, in <module>
hello_world =hello +''+ World
NameError: name 'World' is not defined
Process finished with exit code 1
Python变量区分大小写,因此变量World
与world
不同。
[hello_world =hello +''+ World
应该是hello_world = hello + '' + world