Taking Multiple Inputs From User in python

 

# Python program showing how to
# multiple input using split
 
# taking two inputs at a time
x, y = input("Enter a two value: ").split()
print("Number of boys: ", x)
print("Number of girls: ", y)
print()
 
# taking three inputs at a time
x, y, z = input("Enter a three value: ").split()
print("Total number of students: ", x)
print("Number of boys is : ", y)
print("Number of girls is : ", z)
print()
 
# taking two inputs at a time
a, b = input("Enter a two value: ").split()
print("First number is {} and second number is {}".format(a, b))
print()
 
# taking multiple inputs at a time
# and type casting using list() function
x = list(map(int, input("Enter a multiple value: ").split()))
print("List of students: ", x)

Output: 

Enter a two value: 5 10

Number of boys: 5

Number of girls:10


Enter a three value: 30 10 20

Total  number of students : 30 

Number of boys is : 10

Number of girls is : 20



Enter a two value: 10 20 

First number is 10  and second number is 20 



Enter a multiple value: 10 20 30 40 50 

List of students:  [10, 20, 30, 40, 50]



Comments

Popular posts from this blog

XAMPP, SQL BASIC COMMANDS

The Minion Game Hackerrank Solution

Arrays - DS | HackerRank Solutions