Python Forum
Matching variable to a list index
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matching variable to a list index
#7
(Nov-28-2020, 02:13 AM)bowlofred Wrote: Lots of globals make it hard to keep track of everything.

Is the output supposed to be the "right answer"? I don't see where you store that. You use a function to ask for the right answer, but that function doesn't seem to store it anywhere.

There is also a lot of stuff in that function that is only inside the exception block. That may be incorrect, but doesn't change that nothing is storing the data. Also, on error you are calling the same function, Recursion here is a poor idea. You should be looping instead of making another call.

Thanks for your reply,
That's the technique my professor tought me.
I'm trying to make it as dynamic as possible by letting the user decide how many answer's a question will have.
the "right" answer can, in fact, be anything. for me it's the answer's number that count.
Could you show me an example of looping that? or maybe a more efficient way to do it?

Thanks again!
Reply


Messages In This Thread
Matching variable to a list index - by Gilush - Nov-28-2020, 01:28 AM
RE: Matching variable to a list index - by Gilush - Nov-28-2020, 01:51 AM
RE: Matching variable to a list index - by Larz60+ - Nov-28-2020, 02:04 AM
RE: Matching variable to a list index - by Gilush - Nov-28-2020, 02:10 AM
RE: Matching variable to a list index - by Gilush - Nov-28-2020, 02:29 AM
RE: Matching variable to a list index - by Gilush - Nov-28-2020, 11:05 AM
RE: Matching variable to a list index - by Gilush - Nov-28-2020, 11:42 AM
RE: Matching variable to a list index - by Gilush - Nov-28-2020, 05:58 PM
RE: Matching variable to a list index - by Gilush - Nov-28-2020, 07:18 PM
RE: Matching variable to a list index - by Larz60+ - Nov-29-2020, 04:10 PM
RE: Matching variable to a list index - by Gilush - Nov-29-2020, 09:44 PM
RE: Matching variable to a list index - by Larz60+ - Nov-30-2020, 01:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable for the value element in the index function?? Learner1 8 748 Jan-20-2024, 09:20 PM
Last Post: Learner1
Thumbs Down I hate "List index out of range" Melen 20 3,552 May-14-2023, 06:43 AM
Last Post: deanhystad
  IndexError: list index out of range dolac 4 1,998 Jul-25-2022, 03:42 PM
Last Post: deanhystad
  Split string using variable found in a list japo85 2 1,362 Jul-11-2022, 08:52 AM
Last Post: japo85
  IndexError: list index out of range Anldra12 2 1,494 May-03-2022, 01:39 PM
Last Post: Anldra12
  IndexError: list index out of range rf_kartal 6 2,930 Sep-07-2021, 02:36 PM
Last Post: Larz60+
  Python Error List Index Out of Range abhi1vaishnav 3 2,410 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav
  An IF statement with a List variable dedesssse 3 8,528 Jul-08-2021, 05:58 PM
Last Post: perfringo
  IndexError: list index out of range Laplace12 1 2,265 Jun-22-2021, 10:47 AM
Last Post: Yoriz
  IndexError: list index out of range brunolelli 11 6,742 Mar-25-2021, 11:36 PM
Last Post: brunolelli

Forum Jump:

User Panel Messages

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