Python Forum
beginner and need help with python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
beginner and need help with python
#11
I thought line 11 will stop the endless beer as in if the number entered is less than 1 then no beer will be served. I might be wrong but thats what the purpose was for that else clause.
Reply
#12
But if i starts at 10, it never changes, so it's beer forever. Somewhere in the loop you need to decrement i
Reply
#13
you can specify a condition only with if and elif
if i == 6:
   print("we have 6 juice")
elif i == 0:
   print("we have no juice")
elif i == 1 or i == 2:
   print("you have 1 or 2 juice")
else:
   print("we have enough of juice")
The elif statement allows you to check multiple expressions.
An else statement contains the block of code that executes if and elif conditional expression in the if statement resolves to 0 or a FALSE value.
Reply
#14
Here is a decent example of how to increment and decrement in Python, specifically the augmented assignment operators section toward the end the page.

Increment and decrement
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020