← Back to all posts
I am having trouble understanding why this code isn't working, could someone please help me out?

https://repl.it/@Matt359/My-Quiz I am having trouble understanding why this code isn't working, could someone please help me out?

lsambrook (286)

Try this :

B = banana
A = biscuit
C = input("Which Spider is The Deadliest? Is it option A, The biscuit? or option B the banana? "
if C == A
print("maybe")
else
print("maybe")

ash15khng (472)
``````print ("Which Spider is The Deadliest?")

print ("Is it option A, The Red Back?, or option B, The Funnel Web?")

if input is 'B' print ("Hi")
if input is 'A' print ("They are both very poisionous that makes them very deadly.")``````

So first, you have to understand that though Python is quite friendly in terms of syntax, writing proper English sentences doesn't work (lol).

To get input, you use `input()`, like this:

``a = input("text that you want to display")``

This sets `a` to whatever the user typed in.

Comparing for equality works like this:

``````if a == "hello":
print("the user typed hello")``````

This checks if `a` was `"hello"`, and if it is it runs the print statement.

So your code should be something like this:

``````print ("Which Spider is The Deadliest?")

d = input("Is it option A, The Red Back?, or option B, The Funnel Web?")

if d == 'B':
print ("Hi")
if d == 'A':
print ("They are both very poisionous that makes them very deadly.")``````
ash15khng (472)

@Matt359 If this helped, please mark it as the answer!

mwilki7 (519)

What is it you want your code to do?

Matt359 (0)

@mwilki7 I want it to have a quiz game, then I want it to display the answer and see if you got it wrong or right, for about 20 questions.

mwilki7 (519)

@Matt359
You could try pairing the question with an answer using pairs.
For instance:

``````q1 = ('What are clouds made of?', 'Water')
q2 = ('What is Aurora Borealis mean?', 'Northern Lights')
# q1[0] gets the question, q1[1] is the answer
# same thing for q2, q3...and so on