For school I have to write a program that requests a 3 part name and breaks it into a first, middle, and last name. I wrote the code but the alignment of my output is not right. I was wonderng if someone can tell me what I did wrong and how to fix it. Any help would be appreciated. Thanks! I am a beginner at Python. The code has to be very simple like for a kidnergartener and it has to follow the format of the code I already wrote and has to work with any name I type in and has to use the .find() function. No loops or if else statements can be used.
def main():
name=input("Please enter a full name with 3 names, separated by one space: ")
space=name.find(" ")
first=name[:space]
middle=name[space+1:]
secondname=middle[:space]
last=middle[space:]
print(first)
print(secondname)
print(last)
main()
Output:
Please enter a full name with 3 names, separated by one space: francis ford coppola
francis
ford co
ppola
Please enter a full name with 3 names, separated by one space: billy dee williams
billy
dee w
illiams