Im confuse about the lesson conditionals--control-flow/exercises of python


#1

i m doing the last exercice of the class conditionnal
i tried to create my own code and I get some errors for the last code , under 700
but even when i dont get errors i gont get the results exepected

with the result 850 im supposng to get " return “I buy a dog”" and i get “but wine”
the same for the result : 1

any ideas!!? thanks


def win_loto (win):
    if win >= 100000:
		return "I buy a castle"

    elif win_loto>=3000:
       return "I buy 100 wine bottles"

    elif win_loto>=800:
        return "I buy a dog"
      
    else win_loto<700:
         return "I sleep under some bridges"


print win_loto (120000)
print win_loto (5000)
print win_loto (850)
print win_loto (1)

#2

comparing a function (win_loto) and an integer (3000) won’t work. For some reason you do it right in the if condition where you use win (the function parameter), the parameter gets its value from argument at function call.

also, else can’t have a condition, its everything else.


#3

hello, thnaks for your answer,
so you mean it should be >3000 ?
but in the example of the course there was =>


#4

Is my answer that terrible? Its not about the comparison operator, its about the variable(s) you use in the comparison.


#5

Hi :blush:

I think stetim94 is talking about these:

if win >= 100000:

elif win_loto>=3000:

elif win_loto>=800:

(I like your program by the way :laughing:)


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.