nebula234
nebula234

Reputation: 17

Python input and random system

I'm making an input system that asks for the user if the user selects low or high and then prints out if it's low or high with:

print(random.randint(1, 2))

But it gives this error:

  File "main.py", line 13
    print(random.randint(1, 2))
                              ^

IndentationError: unindent does not match any outer indentation level

pls debug me here's the code

import random
print("Hello Welcome to the up down game!")

while True:

  first = input("[1]Low or [2]High. Which one?\n")


 print(random.randint(1, 2))
break

Upvotes: -1

Views: 98

Answers (2)

I'mahdi
I'mahdi

Reputation: 24049

in python you should be careful on Indentation, see code below: (see this ref)

import random
print("Hello Welcome to the up down game!")
while True:
    first = input("[1]Low or [2]High. Which one?\n")
    print(random.randint(1, 2))
    break

Upvotes: 1

Sarvesh M.D
Sarvesh M.D

Reputation: 360

You have indented your code wrong.

import random
print("Hello Welcome to the up down game!")
while True:
    first = input("[1]Low or [2]High. Which one?\n")
    print(random.randint(1, 2))
    break

Try this and it will work !

Upvotes: -1

Related Questions