0 votes
1 view
in Python by (47.8k points)

level: beginner

def play_game(word_list): 

hand = deal_hand(HAND_SIZE) 

while True:

cmd = raw_input('Enter n to deal a new hand, r to replay the last hand, or e to end game: ') 

if cmd == 'n':

hand = deal_hand(HAND_SIZE) 

play_hand(hand.copy(), word_list) 

print 

elif cmd == 'r':

play_hand(hand.copy(), word_list)

print 

elif cmd == 'e':

break

else:

print "Invalid command."

my question: while WHAT is True?

I reckon to say 'while true' is shorthand but for what? while the variable 'hand' is being assigned a value? and what if the variable 'hand' is not being assigned a value?

1 Answer

0 votes
by (107k points)

The code statement While True means until the code inside while loop is  True. The while loop will run as long as the conditional expression evaluates to True.

Since True always evaluates to True, the loop will run indefinitely, until something within the loop returns or breaks.

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
2 answers
0 votes
1 answer
asked Oct 4, 2019 in Python by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
2 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...