I have a string variable (mystring
). In a while loop the user can input the content of the string and I want to break the loop when it contains the letter 'a'
and the letter 'b'
. I tried the following:
mystring = ''
while 'a' or 'b' not in mystring:
mystring = input('write:')
the while loop works perfect if I use just one of the letters (no or
statement).
If I check mystring e.g. after inputting 'abacjihgea'
using
'a' and 'b' in mystring
it returns True
. Shouldn't it break the while loop then?
Unfortunately I can't seem to fix this problem.