'FOR' fora da função:
permissions = []
ages = [10, 50, 30, 12, 18]
print('-=-'*10 , 'For fora da função' , '-=-'*10)
def driving_age_verification (age):
if (age < 18):
print(f'If you have {age} years old, you cant drive!')
else:
print(f'If you have {age} years old, you can drive!')
for age in ages:
driving_age_verification(age)
'FOR' dentro da função:
permissions = []
ages = [10, 50, 30, 12, 18]
print('-=-'*10 , 'For dentro da função' , '-=-'*10)
def driving_age_verification (ages):
for age in ages:
if (age < 18):
print(f'If you have {age} years old, you cant drive!')
else:
print(f'If you have {age} years old, you can drive!')
driving_age_verification (ages)
'Booleanos'
'Booleanos':
permissions = []
ages = [10, 50, 30, 12, 18]
def driving_age_verification (ages,permissions):
i = 0
for age in ages:
if (age < 18):
permissions.append(False)
else:
permissions.append(True)
if (permissions[i] == True):
print(f'If you have {age} years old, you can drive!')
else:
print(f'If you have {age} years old, you cant drive!')
i += 1
driving_age_verification(ages,permissions)