Skip to content
techsnow

Python Basics

Input and Output

print()

print("Hello", "world")            # Hello world
print("a", "b", "c", sep="-")      # a-b-c
print("No new line", end=" ")
print("after")                     # No new line after

input()

input() shows a message, waits for the user to type and press Enter, and returns what they typed as a string.

name = input("What is your name? ")
age = int(input("How old are you? "))
print(f"Nice to meet you, {name}! Next year you'll be {age + 1}.")

Output

What is your name? Bilal
How old are you? 20
Nice to meet you, Bilal! Next year you'll be 21.