-
Notifications
You must be signed in to change notification settings - Fork 1
Input
upizpp edited this page Jan 13, 2024
·
2 revisions
Similar to io.print()
, you must import the io
module first. There are only two ways to input values in PhiScript.
import io;
var x = io.input(<prompt>);
import io;
var x = io.input("Whats your name?");
io.print(x);
import io;
var x = io.get_number(<prompt>, <output after input a invalid number>);
io.get_number()
is similar to this Python code:
def get_number(input_tip, bad_value, white_list):
while(True):
try:
s = input(input_tip)
if s in white_list:
break
x = int(s)
break
except ValueError:
print(bad_value)
import io;
var x = io.input("How old are you:", "Invalid input:");
io.print(x);