Coding in Python 13 – User Input

In video number 13 of the Coding in Python series, you’ll learn how to accept input from the user.

YouTube player

Commands Used in this Video

Simple example of capturing user input and printing it

#!/usr/bin/env python3
  
print("Enter your name:")
name = input()
print(name)

More efficient input example

#!/usr/bin/env python3

name = input("Enter your name:\n")
print(name)

An example of using input in a string

#!/usr/bin/env python3

name = input("Enter your name:\n")
print("Your name is " + name)

An example of using input in a string

#!/usr/bin/env python3

age = input("Enter your age:\n")
print("You are " + age + " years old")

age2 = int(age) + 50
print("In 50 years, you will be " + str(age2) + years old.")

Brand-New Course!

Check out Jay’s new course on Ansible and start automating today!

Discount Vouchers


Receive 5% off an LPI exam voucher!

Exclusive Member Features

Support the channel and receive exclusive perks!