Learn to Code via Tutorials on Repl.it!

← Back to all posts
how to use the Python if and else Function
gatorade322

This repl shows how to use the if and else function. If you run it many times, you will see that there are two endings. Also try to figure out how it works.

Voters
JacobSedgebeer
gatorade322
Comments
hotnewtop
[deleted]

You know, you could just combine the tutorials together. The tutorials arent good either. You didnt explain how they work, you just showed code, like your asking for cycles

AidenTV1

the 9th row(program)

AidenTV1

why is this working
import random

rannum = random.randint(1, 100)

print("The random number is within 1 ~ 100")
while(true):
playernum1 == int(input("What number will you chose? 1 to 100.\n"))

if playernum1 == rannum :
print("congrets!")

elif playernum1 <= rannum :
print("a little higher!")

else:
print("a little more lower!")

gatorade322

Wow, I made this a long time ago. Now I see how bad the quality of my tutorial was! (: I'll try to make some better ones in the future.

AidenTV1
JacobSedgebeer

thanks this helped a lot! I couldn't figure out how to do the randomized randit

gatorade322

k