Python Forum
Thread Rating:
  • 2 Vote(s) - 1.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Shuffle List
#11
(Oct-21-2016, 02:06 PM)sparkz_alot Wrote: Well, you have a lot going on and to be honest, makes very little sense. For instance, in line 45 you have "svar = 0" yet you never use "svar". Line 49 you have "int()" but it relates to nothing. Line 51, you have
 if sv == slumpFråga:  # if-sats answer = randomquestion     print("Correct!") 
but "sv" will never be comparable to "slumpFraga" because "sv" is a list and "slumpFraga" is a string, so you will always get "False" You really need to understand the basics. The link posted by metulbuur is very good and there are many, many tutorials out there for beginners.
Here is a very simply example, see if you can follow along with what is happening.
 import random question = ["Are you happy", "Are you sad"] choices = ["yes", "no"] rand_question = random.choice(question) print("The question is: ", rand_question) answer = input("What is your answer? ") if answer in choices:     print("Your answer is True") else:     print("Your answer is False") 
Start off small and once it works, slowly build up from there. Use variable names that make sense. When you print something, make sure you let yourself and others know what it is your printing. And use "print" statements liberally, to make sure variables contain what they ought to contain and your program is progressing as you intend. Good luck Smile
Okey thank you, this helped alot!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Random selection from list Mohsky 1 8,819 Mar-31-2020, 10:27 PM
Last Post: deanhystad
  printing list of random generated rectangles Zatoichi 8 7,285 Feb-18-2018, 06:34 PM
Last Post: buran
  bubble sort random list atux_null 7 7,833 Nov-03-2017, 07:28 PM
Last Post: sparkz_alot
  List with Random Numbers AnjyilLee 5 9,259 Oct-14-2017, 09:22 PM
Last Post: buran
  Using two functions to shuffle a deck of cards bwe587 7 9,099 Feb-15-2017, 08:15 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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