2
List value assignment
NoR3gr3t (1)

I'm trying to write a code that will accept up to three sets of name inputs and then switch from first last to last first format. Whenever the code is run if assigning more than one name it will remove the assignment for the previous names. I have six days to finish this.
import sys
namesInput = 0
enteringNames = True
while(namesInput < 3 and enteringNames == True):

fname = ['','','']
lname = ['','','']
fname[int(0 + int(namesInput))] = str(input("Input a first name.\n"))
lname[int(0 + int(namesInput))] = str(input("Input a last name.\n"))
namesInput = namesInput + 1
print('Would you like to input another name? You have input ' + str(namesInput) + ' so far.\nYes(1) or No(2)')
answer = int(input())
if(answer == 2):
enteringNames = False
while(namesInput > 2 or enteringNames == False):
if(namesInput == 1):
print('Your swapped name is:\n' + lname[0] + ', ' + fname[0])
if(namesInput == 2):
print('Your swapped names are:\n' + lname[0] + ', ' + fname[0] + '\n' + lname[1] + ', ' + fname[1])
if(namesInput == 3):
print('Your swapped names are:\n' + lname[0] + ', ' + fname[0] + '\n' + lname[1] + ', ' + fname[1] + '\n' + lname[2] + ', ' + fname[2])
break

You are viewing a single comment. View All
1
heyitsmarcus (285)

@NoR3gr3t Ah! awesome! I'm glad you figured it out. Happy Coding! =]