Python Forum
2 if statements happening at the same time
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 if statements happening at the same time
#1
hi I'm looking at all these other forum posts and they seem a lot more complex so sorry if this is a waste of time

im really new to python but i cant put my finger on exactly why the /cash condition happens when i input /chop ik its gunna be really obvious but i honestly have no idea why this happens
import time

cash = 15
logs = 5
rocks = 5
bricks = 0
planks = 0
a = True

while a:
  action = input("")
  if action == "/cash" or "/money":
    print("\n")
    print(cash, "$")
  if action == "/chop":
    print("\n")
    print("chopping...")
    time.sleep(5)
    logs += 1
    print("you chopped a tree. you now have", logs, "logs")
result:
Output:
/chop 15 $ chopping... you chopped a tree. you now have 6 logs
please help me
Yoriz write Nov-19-2022, 11:22 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
2 if statements happening at the same time - by M0TH - Nov-19-2022, 10:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb What's happening here? jesse68 3 1,062 Feb-27-2023, 04:53 PM
Last Post: Gribouillis
  Why is this happening? taner7 3 2,315 Oct-14-2020, 10:11 PM
Last Post: Skaperen
  Binding not explicitly declared happening karkas 4 3,069 Aug-05-2019, 05:09 PM
Last Post: karkas
  Why this python ValueError is not happening aurquiel 2 3,153 Aug-20-2018, 07:17 PM
Last Post: aurquiel
  Something strange happening here !? TerryRitchie 4 4,044 Apr-20-2017, 07:14 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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