我正在尝试打印您有资格获得的东西,如果您没有资格获得其中任何一项,我正在尝试打印您没有资格获得其中任何一项。但是使用此代码,它总是将 else 与 if 一起打印
PS:我1个月前开始编程。
print('Task 2')
print()
name = str(input('Navn: '))
age = int(input('Age: '))
gender = str(input('Gender (f for female, m for male): '))
children = int(input('How many children: '))
repute = int(input('repute, on a scale from 1(bad) to 9(immaculate): '))
record = str(input('record (done time/convicted/suspect/clean): '))
seniority = int(input('seniority (years): '))
print()
member = gender == 'f' and age >= 20 and repute <= 7
solder = gender == 'f' and age >= 20 and age <= 30 and repute <= 7 and children == 0
sargent = gender == 'f' and age >= 20 and age <= 30 and repute <= 7 and children == 0 and seniority >= 4 and record != 'clean'
captain = gender == 'f' and age >= 20 and age <= 40 and repute <= 7 and seniority >= 6 and record == ('done time' or 'convicted')
commander = gender == 'f' and age >= 20 and age <= 40 and repute <= 3 and seniority >= 6 and record == ('done time' or 'convicted')
president = gender == 'f' and age >= 20 and age <= 40 and repute <= 2 and seniority >= 8 and record == ('done time' or 'convicted') and name != 'kim'
print('You are eligible to become:')
if member == True:
print('Member')
if solder == True:
print('Solder')
if sargent == True:
print('Sargent')
if captain == True:
print('Captain')
if commander == True:
print('Commander')
if president == True:
print('President')
else:
print('You are not eligible to be a member')
暮色呼如
互换的青春
aluckdog
相关分类