-2

while party!='R' and party!='D':

can this be shortened to

while party!='R' and 'D':

while party!=('R' and 'D'):

or the like? (that is, is there any equivalent expression with only one party!=)

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
user84614
  • 1
  • 3

2 Answers2

0

If you want to use multiple condition:

try this.

l=['R','D']
while party not in l:
Mehmaam
  • 573
  • 7
  • 22
0

you can simply create list and use like this

validList = ['R', 'S']
# You can also use not in operator for other condition
if party in validList:
    # Do your stuff here
    print("It's Present")
RA17H45M40S
  • 113
  • 1
  • 6