+ 3

What am I doing wrong here?

Obviously a syntax issue, I tried with and without parentheses, tinkered around with it, but the last thing I want to do is paste it into AutoGPT and have her fix it and make me pancakes while changing my brakes on the car and curing Cancer while massaging my feet 😆 --------------- #sets the value of age age = int(input()) if age (>= 18) and (<= 74): # executed only if customer is over-age print("Regular price") elif (age >= 75) and (<= 99): #executed only if age is less than 18 print("Discount Price, You Old Croaker") elif age >= 100: print("Are you gonna die? Take this at no charge!") else age < 18: print("No charge")

26th Sep 2023, 1:14 PM
James Nesbitt Jr
James Nesbitt Jr - avatar
5 ответов
+ 5
try this code: the syntax in the if statments was incorrect, and else statments cannot have a condition 😄 #sets the value of age age = int(input()) if age >= 18 and age <= 74: # executed only if customer is over-age print("Regular price") elif age >= 75 and age <= 99: #executed only if age is less than 18 print("Discount Price, You Old Croaker") elif age >= 100: print("Are you gonna die? Take this at no charge!") elif age < 18: print("No charge") else: print("No charge")
26th Sep 2023, 1:21 PM
Defying Gravity
Defying Gravity - avatar
+ 3
age = int(input()) if 18 <= age <= 74: print("Regular price") elif 75 <= age <= 99: print("Discount Price, You 0ld Croaker") elif age >= 100: print("Are you gonna die? Take this at no charge!") else: print("No charge") You had 2 errors 1. You weren't assigning your variable to your AND condition 2. You assigned a condition to your ELSE, which is designed to return a statement when no other conditions are met
26th Sep 2023, 10:24 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
#sets the value of age age = int(input()) if age (>= 18) and (<= 74): # executed only if customer is over-age print("Regular price") elif (age >= 75) and (<= 99): #executed only if age is less than 18 print("Discount Price, You Old Croaker") elif age >= 100: print("Are you gonna die? Take this at no charge!") else: print("No charge")
27th Sep 2023, 6:09 PM
Fateme Biglari
Fateme Biglari - avatar
+ 1
Thank you both. The first reply worked. The second and third solution pulled an error due to the parentheses around the greater than and equal to logic condition Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), __main__.__dict__) File "<string>", line 3 if age (>= 18) and (<= 74): ^ SyntaxError: invalid syntax [Program finished]
28th Sep 2023, 1:59 AM
James Nesbitt Jr
James Nesbitt Jr - avatar
0
you wrote syntax wrong, after else you gave it condition age <18❌ change it to elif✅
4th Oct 2023, 11:33 AM
faraz samiee
faraz samiee - avatar