Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code does not complete
#1
x = int(input("Enter the number of apples: "))
c = input("what do you want to do with the apple?: ")
if x == 1:
    print("got it")
elif x == 2:
    print("got it")
if c == "store it"
    print("apple is stored")
My issue is when i run the code, it completes the final if statement if c == "store it" but only if I enter a maximum of 2. If I enter 3+, it will not complete that last if statement. Can someone guide me in the right direction?

the actual code is much longer but the same idea. I was thinking maybe the code is too long and by the time it reaches that last if statement it forgets what c was equal to?
Reply
#2
if c == "store it" is missing a : from the end.
The result of input value stored in x has no influence over the if c == "store it": statement.
It doesn't matter how long the code is , it will not forget the value of c.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  (Complete Novice) Code not working PythonGainz 9 4,096 Mar-21-2020, 05:53 PM
Last Post: buran
  complete newbie, trying to tweak some code notarobot 6 3,154 Nov-02-2019, 03:35 PM
Last Post: notarobot
  Can someone help me alter/complete my python 3.7 code kathyadventure94 1 2,494 Nov-22-2018, 04:12 PM
Last Post: ichabod801
  Complete Beginner Startup - Simply run github code for hpd20 Image_Engine 8 4,693 Apr-23-2018, 11:15 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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