name=input('name:')
gender=input ('Gender (Male: 1, Female: 2):')
soldier=input ('military discharge (for example, 1, no:2)):')
marry=input ("marriage (for example, 1, no:2)):")
if gender=1:
gender=0 and gender1="Men"
elif gender=2:
gender=1 and gender1="female"
if soldier=1:
soltier=1 and soltier1="military service"
elif soldier=2:
soldier=0 and soldier1="not yet completed"
if marry=1:
marry_number=input ("How many children do you have?")
if marry_number=1:
marry=1 and marry1="married"
elif marry_number>=2:
Marry=2 and marry1="Married"
elif marry=2:
marry=0 and marry1="single" and marry_number=0
print("%s" is %s, %s, and %s. The additional points are %d because the number of children is %d." %name, %gender1, %solder1, %marry1, %marry_number, %gender+solder+marry)
It's my first time to make a file like a picture into Python, so I just made it up, but it's called ifgender=1: This invalid syntax. Please help me
Use =
to assign a value to a variable.
Use ==
to compare and determine whether the conditional statement has the same value.
Also, when assigning values to variables, do not connect them with and write each on a single line or
a, b = 1, 2
You can do it the same way.
To add a word, the code you wrote seems to require you to study Python grammar from scratch before you solve the problem.
Even if you can't fully understand all the functions of Python from the beginning, I don't want to recommend that you should try to make a code first without knowing the very basic things.
© 2024 OneMinuteCode. All rights reserved.