+ 2
How would you make a voting test
when the person enter their age and the test either says they are of age or not 18 to vote
12 Antworten
+ 10
age = eval(input())
if age >= 18 and age != "":
print("You can vote")
else:
print("You can't vote")
#You should add more controls, this is just a basic start
# I hope this is not your homework ^_^
+ 9
age = int(input("enter your age: ")) //inputs age
print(age) //prints value of age
print("#######################\n")
if age >= 18: //checks age to see if voting possible
print("You can vote")
else:
print("You must at least 18 to vote")
//Code by Wisdom
+ 9
First declare the age and secondly testing for the value of age. Take Sololearn Python course to understand better.
+ 8
https://code.sololearn.com/cIAUguMGwrzp/?ref=app
With exception handling
+ 8
With the Python's course. =^=
+ 6
You need the age because you're testing for it.
Without the age you wouldn't know whether the user is eligible to vote or not.
+ 3
This gives me a great idea thank you
+ 3
I'm very new to it, don't want the exact code. just want to know where to start
+ 1
I am thank you. Everyone I see a new code it's just nice to understand.. I have some basics down.
0
why is it that I need AND AGE in that code? I was able to run it but is someone able to explain. for future purposes?
0
I get that, but why is age in the code twice?