Oct-24-2016, 04:02 PM
(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 haveOkey thank you, this helped alot!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