Python Forum
New to python, starting from scratch
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to python, starting from scratch
#1
Big Grin 
questions = ["What is your name?", "What is your favorite color?", "What is your quest?"]
n = 0
while True:
    print("Type q to quit")
    answer = input(questions[n])
    if answer == "q":
        break
    n += 1
    if n > 2:
        n = 0
abouv is a some code I don't get. If I remove all the questions but one, this code give the following error:

Error:
line 5, in <module> answer = input(questions[n]) IndexError: list index out of range
I cannot find what is the matter Wall
Yoriz write Apr-16-2021, 01:19 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
New to python, starting from scratch - by Pythnoobvent1971 - Apr-16-2021, 11:34 AM
RE: New to python, starting from scratch - by Yoriz - Apr-16-2021, 01:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Starting over with Python Mark17 1 486 Sep-29-2023, 07:16 PM
Last Post: Larz60+
  [split] Kera Getting errors when following code example Image classification from scratch hobbyist 3 4,604 Apr-13-2021, 01:26 PM
Last Post: amirian
  starting python from windows command prompt MaartenRo 4 2,797 Sep-04-2020, 12:25 PM
Last Post: MaartenRo
  Restarting code from scratch palladium 1 1,997 Feb-29-2020, 04:46 PM
Last Post: ibreeden
  Issue starting Python on VSC (Nooby) Buggy 1 2,044 Mar-14-2019, 09:44 PM
Last Post: snippsat
  python 'SMTP debugging server' not starting local error pcsailor 1 3,438 Nov-26-2018, 10:13 PM
Last Post: micseydel
  Starting to learn python on a Mac asifhoss 8 8,145 Jan-03-2018, 08:29 PM
Last Post: karaokelove

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020