请问程序哪里出错?
我按照书籍所示用Visual Studio Code编写代码,在终端运行却只能运行一般,不然就会出错了。求救求救......代码:
# 定义一个函数
def get_formatted_name(first_name, last_name):
"""返回简单的用户名"""
full_name = first_namt + ' ' + last_name
return all_name.title()
# 在循环中载入实参
while True:
print("\nPlease Enter Your Name")
print("(Enter 'q' any time to quit)")
first_name = input("First Name: ")
if first_name == 'q':
break
last_name = input("Last Name: ")
if last_name == 'q':
break
formatted_name == get_formatted_name(first_name,last_name)
print("Hello" + formatted_name + "!")
报错:
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>C:/Users/Administrator/AppData/Local/Programs/Python/Python38-32/python.exe e:/我的Python文件/002.py
Please Enter Your Name
(Enter 'q' any time to quit)
First Name: Z
Last Name: AY
Traceback (most recent call last):
File "e:/我的Python文件/002.py", line 18, in <module>
formatted_name == get_formatted_name(first_name,last_name)
NameError: name 'formatted_name' is not defined
C:\Users\Administrator>