Input Examples

Accepting a string input:


            name = input("Please enter your name: ")
            print("Hello " + name + "!")
        

Output:


            Please enter your name: John
            Hello John!
        

Accepting an integer input:


            age = int(input("Please enter your age: "))
            print("You will be " + str(age + 1) + " next year!")
        

Output:


            Please enter your age: 25
            You will be 26 next year!
        

Accepting multiple inputs as a list:


            numbers = input("Please enter some numbers separated by a space: ").split()
            sum = 0

            for number in numbers:
                sum += int(number)

            print("The sum of the numbers is:", sum)
        

Output:


            Please enter some numbers separated by a space: 10 20 30
            The sum of the numbers is: 60
        

Accepting multiple inputs as separate variables:


            x, y, z = input("Please enter three numbers separated by commas: ").split(",")
            print("The three numbers are:", x, y, z)   
        

Output:


            Please enter three numbers separated by commas: 1,2,3
            The three numbers are: 1 2 3