- #1
- 7,318
- 11,146
Hi, I am taching myself Python 3.7.2.
I think I get how 'While True' statements work,
but I am having trouble making sense of this. The program runs, but I would like to understand well what
is the condition being tested. (From 'Automate the Boring Stuff with Python)
We have a dictionary of people and their birthdates. We want to see if someone's is in a key, i.e., is in the
dictionary. If they are in the dictionary, we acknowledge them. If they are not, we ask for their birthday and then add them into the dictionary. I get that 'While True' statements loop until the condition described in it is not realized/met. *.
*Assume program is well-written, will not loop infinitely.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
Thanks.
I think I get how 'While True' statements work,
but I am having trouble making sense of this. The program runs, but I would like to understand well what
is the condition being tested. (From 'Automate the Boring Stuff with Python)
We have a dictionary of people and their birthdates. We want to see if someone's is in a key, i.e., is in the
dictionary. If they are in the dictionary, we acknowledge them. If they are not, we ask for their birthday and then add them into the dictionary. I get that 'While True' statements loop until the condition described in it is not realized/met. *.
*Assume program is well-written, will not loop infinitely.
Python:
BirthdayDictionary = { 'Name1': 'Date 1',..., 'Namen' :'Daten ' }
while True:
print('Enter a name: (blank to quit)')
name = input()
if name == '':
break
if name in dictionary:
print( BirthdayDictionary[name] + 'Is the Birthday Of ' name )
else:
print('I have no info on' + name)
print(' What is the birthday of ' + name? )
bday =input()
BirthdayDictionary[name]=bday
print('Database has been updated')
Thanks.