interactive list, finish my noob code! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

interactive list, finish my noob code!

Trying to play with lists and i want to only enter a number to get one out of 6 alternatives. This is the code, maby you will understand where i want to get: alts = [ "alt1", "alt2", "alt3", "alt4", "alt5", "alt6", ] question = input("what alt? ") answer = input(question) def question(question): if answer == 1: print(alts[0]) elif input("2"): print(alts[1]) else: print("and so on") ------------------------------------ Of course its not full, but can someone write down a full code fo this?

14th Dec 2018, 5:25 PM
johan suup
johan suup - avatar
4 Answers
+ 2
answer=int(input()) if(answer >=1 and answer <=6): print(alts[answer-1])
14th Dec 2018, 5:38 PM
Rishi Anand
Rishi Anand - avatar
+ 1
got it: alts = [ "alt1", "alt2", "alt3", "alt4", "alt5", "alt6", ] answer = int(input()) if (answer >= 1 and answer <= 6): print(alts[answer - 1]) wery much thanks!
14th Dec 2018, 6:37 PM
johan suup
johan suup - avatar
0
ok im in over my head, back to the tutorials!:O thanks anyway!!
14th Dec 2018, 6:18 PM
johan suup
johan suup - avatar
0
writing in python 3 btw
14th Dec 2018, 6:19 PM
johan suup
johan suup - avatar