每当我尝试显示带有第一个初始连接到末尾的名字时,我会得到一个超出字符串索引范围的错误!操纵字符串返回连接的用户名
def ForeName():
return raw_input("Please enter your Forename: ")
def MiddleName():
return raw_input("please enter your middle name, if none leave blank: ")
def LastName():
return raw_input("Please enter your last name: ")
def Test():
ForeNameT = ForeName()
MiddleNameT = MiddleName()
LastNameT = LastName()
if not MiddleNameT:
first_username = ForeNameT[0:] + LastNameT[0]
elif ForeNameT:
first_username = ForeNameT[0:][0] #i want to display the first name with the initial of the first name attached to the end of the first name.
else:
first_username = ForeNameT[0:] + MiddleNameT[0]
return first_username
print Test()
我有一个大概的想法,我需要调用你刚刚用于打印测试()行的参数,只是不知道该怎么做!正如我所说,没有寻找答案,只是更简洁的信息,关于我试图做什么。 –
如何将参数传递给函数?试着找出如何做到这一点的谷歌搜索。 – yper