8. Your own while/else


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

  1. your own while/else

<In what way does your code behave incorrectly? Include ALL error messages.>

if guess = 3

invalid syntax

<What do you expect to happen instead?>

```python

Replace this line with your code.

from random import randint

Generates a number from 1 through 10 inclusive

random_number = randint(1, 10)

guesses_left = 3

Start your game!

while count > 0:
guess = int(raw_input("Your Guess Here: "))
if guess = 3:
print “You lose!”
guess_left -= 1
break
else:
print “You Win!”

<do not remove the three backticks above>

#2

This line:

if guess = 3

you want to compare, use 2 equal signs, a single equal sign is for assigning a value to a variable


#3

Thank you, that worked. It didn’t before but I understand… so for conditional statements, there must be a comparison? or not always?


#4

you must have done == before, it is impossible you didn’t. Yea, you need to compare, or you can do: if True:, that will also work, then the condition is True as well