python函数练习题
写一段代码,用于识别姓名(first_name,last_name)
结合使用函数get_formatted_name()和while循环,以更正规的方式问候用户
面尝试使用名和姓跟用户打招呼
def get_formarted_name(first_name,last_name,middle_name=‘‘): if middle_name: full_name=first_name+‘ ‘+middle_name+‘ ‘+last_name else: full_name=first_name+‘ ‘+last_name return full_name.title() while True: print("\nPlease tell me your name: ") f_name = input("First name: ") l_name = input("Last name: ") m_name = input("Middle name: ") formatted_name=get_formarted_name(f_name,m_name,l_name) print("\nhello, "+formatted_name+"!") choice=input("\nDo you want tell me another name? (y or n)") if choice == ‘y‘: continue else: break
相关推荐
夜斗不是神 2020-11-17
huavhuahua 2020-11-20
Yasin 2020-11-16
xiaoseyihe 2020-11-16
千锋 2020-11-15
diyanpython 2020-11-12
chunjiekid 2020-11-10
wordmhg 2020-11-06
世事一场大梦 2020-11-17
xiaoseyihe 2020-11-16
Morelia 2020-11-03
CloudXli 2020-11-03
文山羊 2020-10-31
comtop0 2020-10-31
pythonxuexi 2020-10-30
三石 2020-10-29
chaochao 2020-10-27
PythonMaker 2020-10-27