I'm trying to get the user to input the right name, but when I run it keeps asking me to rewrite even when I entered jayson tatum, but when I wrote lebron james it works? Thanks for your inspections Here's the code
while favPlayer != 'lebron james' and 'jayson tatum':
favPlayer = str.lower(input('Favorite player on the list (Lebron James, Jayson Tatum): '))
if favPlayer == 'jayson tatum':
position = 'Small Forward'
print('Your position is Small Forward')
elif favPlayer == 'lebron james':
position = 'Power Forward'
print('Your position is Power Forward')
Here's the run: [enter image description here][1] [1]: https://i.stack.imgur.com/9bem2.png
The issue here is in your
andin yourwhilecondition.andis used to to test two conditions, but here it's testing a condition (favPlayer != 'lebron james) and a string ('jayson tatum').Instead
The reason your attempt ran without error is that any non-zero thing in python is considered
True. So really your while statement was being interpreted as:Which is the same as