Legofan35664
Legofan35664

Reputation: 11

Is it possible to get user input with micro python?

How do I get user input with micro python? Whenever I try using

input()

I get an error saying it is not a valid command. How do i fix this?

Upvotes: 1

Views: 4015

Answers (1)

Russ Hughes
Russ Hughes

Reputation: 174

Use sys.stdin.readline()

import sys

print("What is the Answer to the Ultimate Question of Life, the Universe, and Everything?")
answer = sys.stdin.readline()
if answer == "42\n":
    print("correct!")
else:
    print("incorrect!");

Upvotes: 1

Related Questions