Hello everyone , I wrote this code that I understand except one detail in it , here’s the code :
person_infos(first_name, last_name, age=''):
person = {'first': first_name, 'last': last_name}
if age:
person['age'] = age
return person
a = person_infos('fna', 'lna', age=34)
print(a)
The variable age in the function definition is an empty string , but we when set age as a number ( age = 4 ) no error happens , when we say if age = True , that means age is not an empty string , or it can be even a number ( age being everything except an empty string ) ? Thanks a lot
Thanks for the reply , when you set age = 30 , why do you enter the if statement, because i’ve learned that for a string , a True value means that this string is not empty , but what about numbers , why age is True ( so that if passes ) when you set age to 30 , I think I missed something