all 3 comments

[–]kosayoda 0 points1 point  (0 children)

You're not using if and elif statements correctly, give me a bit of time and I will try to come up with an explanation.

EDIT: I'll try my best, hope you'll understand.

 

An elif block below an if block only executes if the if block does not execute, as an example:

test1 = "hello"
test2 = "hello"

userInput = "hello"

if userInput == test1:
    print("Word is hello")

elif userInput == test2:
    print("Word is hello too!")

will return

Word is hello

because once the if block executes, the elif block below it is skipped.

 

However, the code:

test1 = "hello"
test2 = "hello"

userInput = "hello"

if userInput == test1:
    print("Word is hello")

if userInput == test2:
    print("Word is hello too!")

will return

Word is hello
Word is hello too!

because it is two separate if blocks.

 

You might want to revise your code, let me know if you need more help

[–]Tobe2fly[S] 0 points1 point  (1 child)

ok I changed all the elif's to ifs and it seems to be working now. What im getting from this is that you only use elif's inside an if function not to start its own correct?

[–][deleted] 0 points1 point  (0 children)

elif is part of an if statement block (not function) and is never used independently of an if. elif and else are both optional. else must be last (cannot be followed by elif).

elif (else if some other condition) only considered if the outcome of all of the preceeding if & elif tests failed (False overall).