Skip to content
gene-2012 edited this page Jan 6, 2024 · 1 revision

Input Syntax

Similar to io.print(), you must import the io module first. There are only two ways to input values in PhiScript.

Usage of io.input()

import io;
var x = io.input(<prompt>);

Example of io.input()

import io;
var x = io.input("Whats your name?");
io.print(x);

Usage of io.get_number()

import io;
var x = io.get_number(<prompt>, <output after input a invalid number>);

io.get_number() is similar to this Python code:

while(True):
    try:
        x = int(input("<prompt>"))
        break
    except ValueError:
        print("<output after input a invalid number>")

Example of io.get_number()

import io;
var x = io.input("How old are you:", "Invalid input:");
io.print(x);

Clone this wiki locally