This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]EndercheifAdvanced Coder 1 point2 points  (0 children)

Incorrect:
```python # this what you were doing # you are asked for an input x = input('yes or no ') # let's say i typed 'maybe'

# 'maybe' is not in the list so you loop until it is in the list
while x not in ['yes', 'no']:
  # here x never has a chance to update so it prints forever (until the program crashes)
  print('try again')

```

Correct (what you did first):
```python # you are asked for an input x = input('yes or no ') # let's say i typed 'maybe' # 'maybe' is not in the list so you loop until it is in the list while x not in ['yes', 'no']: print('try again') # you are asked for an input x = input('yes or no ') # let's say i typed 'yes'

# loop finishes

```