Skip to content

How to take multiple inputs in Python | Example code

  • by

Use a split() function to take multiple inputs in Python. This function helps in getting multiple inputs from users. It breaks the given input by the specified separator.

input().split(separator, maxsplit)

Example take multiple inputs in Python

Simple example code takes multiple space-separated inputs without using a while loop.

x, y, z = input("Enter a three value: ").split()
print("Total number of students: ", x)

print("Boys : ", y)
print("Girls : ", z)

Output:

Do comment if you have any doubts or suggestions on this Python input topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading