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 (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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.