samedi 1 février 2020

How to call specific array values within another array

I'm trying to call values in an array. Said values are values from another array I made. Every time I try to run my program I get an error that reads IndexError: list index out of range Is this even a viable thing in python? Here's my code:

answers = []
answers.append("firefighter")
answers.append("policeman")
answers.append("doctor")
answers.append("actor")
answers.append("programmer")
answers.append("youtuber")

job = [answers[0], answers[3], answers[5]]

print("I would like to be a " + job[random.randint(0,2)])



Aucun commentaire:

Enregistrer un commentaire