r/pythonhelp • • Dec 02 '20

Trying to print out the different inputs but not giving the correct output

def inputSwimmers():

inputSwimmers1 = input("Enter lane 1 swimmer: ")
inputSwimmers2 = input("Enter lane 2 swimmer: ")
inputSwimmers3 = input("Enter lane 3 swimmer: ")
inputSwimmers4 = input("Enter lane 4 swimmer: ")
inputSwimmers5 = input("Enter lane 5 swimmer: ")

inputSwimmers()

inputSwimmers = ['inputSwimmers1', 'inputSwimmers2', 'inputSwimmers3', 'inputSwimmers4', 'inputSwimmers5']

swimmers = ["A", "B", "C", "D", "E"]

print("Lists of swimmers are: " , inputSwimmers)

2 Upvotes

1 comment sorted by

1

u/MT1961 Dec 02 '20

I would imagine you are seeing something like:
['inputSwimmers1', ... 'inputSwimmers5']
As your output

When you put the inputSwimmers = ['whatever'...]

you aren't assigning the VARIABLES to the array, you are just assigning the literal strings. Remove the strings:

inputSwimmers = [inputSwimmers1,...] etc

Also, you need to put these variables into the array within the function and return the array. You are assigning them to local variables.