你好,我正在学习python,当我找到列表时,我决定尝试这样的方法:
接收用户全名的输入和返回姓氏的打印以表示欢迎。
nome = []
nome = input("Enter your full name ")
print("Welcome Mr. ", nome[2] )
但是input将每个字符作为列表中的一个新项插入,因此结果是"I“,因为我输入了"LOIP”,而"I“是列表中的第2号。
详细说明:
[0] [1] [2] [3]
[L] [O] [I] [P]
但我想打印的是第二个单词而不是名单