task 4 cho han game:
the user should type ‘odd’ or ‘even’, but if they use ‘Odd’ then code no longer true, how to use. (the answer didn’t talk about this) , i also tested many ways but not work.
#4. cho han
#Makes sure your bet was above 0
if bet <= 0:
print("Your bet should be above 0.")
print('Your money is',money)
print('let guess, you guess',guess)
print('result is even')
print('result is odd')
if ((result1+result2)%2==0 and guess=='even')or ((result1+result2)%2==1 and guess=='odd'):
print('you won', bet,'dollars')
#elif (result1+result2)%2==1 and guess=='odd':
#print('you won', bet,'dollars')
print('you lost', bet, 'dollars')
what happens if you convert it
i use many syntax searched on the internet, str.lower , string.slower(guess) as parameter… error. could you tell me ?
If you convert what they typed to all lower case, then it’ll always be all lower case
Better if you think about what you would need to do instead of testing random things. Pick one, and then think about how you can do that specific thing.
ya, i mean how to do that
i had search and try, so many way and not work. does anybody know?
this guide not about apply to function
You wouldn’t do it any differently just because it’s in a function
A parameter is a variable same as any other, the only difference being that they get assigned when the function is invoked, after that they’re the same.
If you were trying to put code inside the parameter list then yeah you’d have a problem, there’s nothing saying you can do that.
But you can put code in the body of the function, and you’re free to do whatever you want with the values that were given to your function.
i just want a specific answer, if it work then it work.