+ 1

How do i simply choose either of the two names

Understanding syntax/functions of python name1 = 'Jeremy' name2 = 'Monchito' pickname = '' while pickname != name1 or name2: pickname = input('People you know:') print('they are your co workers') It's not working when i pick either

3rd Oct 2022, 1:50 PM
idlejap
idlejap - avatar
3 Respostas
+ 6
networkblue , best way would be what Ipang mentioned. independent from this, the conditional statement in your code was not quite correct. you can do it like this: ... while not (pickname == name1 or pickname == name2): pickname = input('People you know:') ...
3rd Oct 2022, 5:21 PM
Lothar
Lothar - avatar
+ 5
It could be simplified by adding the co-workers' names into a `list` or a `tuple`. We can then use the `in` operator to see whether or not <pickname> exist in the `list` or `tuple`
3rd Oct 2022, 2:19 PM
Ipang
+ 2
Thnks fellow masters 🙂
3rd Oct 2022, 11:08 PM
idlejap
idlejap - avatar