When I insert John J Doe Dole into input as the providedname, the code repeats the first 3 print statements and then displays the last 3 print statements. So, I end up having 9 names instead of the intended 6. It executes all other name combinations perfectly, except for this one (I left the rest of the code out). The purpose of this code is to display all name combinations with a provided name, regardless if its a 2, 3 or 4 word name, as in John Doe, John Joe Doe or John Joe Doe Dole.
print ('Please type the name for naming combinations to be conducted.')
providedname = input()
if len(providedname.split())==4:
firstname, middlename, lastname, secondlastname = providedname.split()
#Provides combination if both the middlename and second lastname have more than 1 character
if len(middlename) and len(secondlastname) > 1:
print ('Combinations for databases with no syntax:')
print (firstname + ' ' + middlename + ' ' + lastname + ' ' + secondlastname)
print (firstname + ' ' + middlename + ' ' + lastname + ' ' + secondlastname[:1])
print (firstname + ' ' + middlename + ' ' + lastname)
print (firstname + ' ' + middlename[:1] + ' ' + lastname + ' ' + secondlastname)
print (firstname + ' ' + middlename[:1] + ' ' + lastname + ' ' + secondlastname[:1])
print (firstname + ' ' + middlename[:1] + ' ' + lastname)
print (firstname + ' ' + lastname + ' ' + secondlastname)
print (firstname + ' ' + lastname + ' ' + secondlastname[:1])
print (firstname + ' ' + lastname)
#Provides combination if the middle name is equal to 1 character and the second last name more than 1 character
elif len(middlename) == 1 and len(secondlastname) > 1:
print (firstname + ' ' + middlename + ' ' + lastname + ' ' + secondlastname)
print (firstname + ' ' + middlename + ' ' + lastname + ' ' + secondlastname[:1])
print (firstname + ' ' + middlename + ' ' + lastname)
print (firstname + ' ' + lastname + ' ' + secondlastname)
print (firstname + ' ' + lastname + ' ' + secondlastname[:1])
print (firstname + ' ' + lastname)
else:
pass