Take Multiple Inputs from User in Python

As a Python developer, while working on a project, I’ve encountered a situation where I needed to collect multiple inputs from users. The challenge isn’t just getting the input – it’s doing it cleanly, efficiently, and in a way that provides a good user experience.

Whether building customer registration systems, data collection tools, or interactive applications, handling multiple user inputs efficiently is a fundamental skill. In this article, I’ll share five proven methods I use regularly to take various inputs from users in Python.

Let’s walk through each approach with practical, real-world examples that you can implement immediately.

Method 1 – Use Multiple input() Functions

The simple approach is to use separate input() functions in Python for each piece of information you need. This method gives you complete control over each input and allows for custom prompts.

Here’s how I typically implement this when collecting customer information for a simple ordering system:

# Collecting customer order information
print("Welcome to Pizza Palace! Please provide your details:")
print("-" * 50)

# Getting individual inputs
customer_name = input("Enter your full name: ")
phone_number = input("Enter your phone number: ")
address = input("Enter your delivery address: ")
pizza_size = input("Choose pizza size (Small/Medium/Large): ")
quantity = int(input("Enter quantity: "))

# Displaying collected information
print("\n" + "=" * 50)
print("ORDER SUMMARY")
print("=" * 50)
print(f"Customer Name: {customer_name}")
print(f"Phone Number: {phone_number}")
print(f"Delivery Address: {address}")
print(f"Pizza Size: {pizza_size}")
print(f"Quantity: {quantity}")
print("=" * 50)
print("Thank you for your order!")

I executed the above example code and added the screenshot below.

python ask for input

This method works well when you need to handle different data types or want to validate each input separately. I often use this approach in professional applications because it’s clear, readable, and easy to maintain.

The main advantage is that each input has its descriptive prompt. Users know exactly what information is expected at each step.

Method 2 – Use split() with Single input()

When collecting related information of the same data type, I prefer using a single input line with Python’s split() method. This method is particularly useful for collecting numerical data or short text entries.

Here’s an example I use for collecting student test scores:

# Collecting student test scores for grade calculation
print("Student Grade Calculator")
print("=" * 30)

# Method 1: Space-separated input
print("Enter student information separated by spaces:")
print("Format: FirstName LastName Math English Science History")
student_data = input("Enter details: ").split()

first_name = student_data[0]
last_name = student_data[1]
math_score = int(student_data[2])
english_score = int(student_data[3])
science_score = int(student_data[4])
history_score = int(student_data[5])

# Calculate average
total_score = math_score + english_score + science_score + history_score
average_score = total_score / 4

# Display results
print(f"\nStudent: {first_name} {last_name}")
print(f"Math: {math_score}")
print(f"English: {english_score}")
print(f"Science: {science_score}")
print(f"History: {history_score}")
print(f"Average Score: {average_score:.2f}")

# Grade assignment
if average_score >= 90:
    grade = "A"
elif average_score >= 80:
    grade = "B"
elif average_score >= 70:
    grade = "C"
elif average_score >= 60:
    grade = "D"
else:
    grade = "F"

print(f"Final Grade: {grade}")

I executed the above example code and added the screenshot below.

input again

You can also use different separators with split(). Here’s an example using comma separation for collecting employee data:

# Employee data collection with comma separation
print("HR Data Entry System")
print("-" * 25)

employee_info = input("Enter: Name, Department, Salary, Years of Experience (comma-separated): ")
name, department, salary, experience = employee_info.split(", ")

# Convert to appropriate data types
salary = float(salary)
experience = int(experience)

# Calculate bonus based on experience
if experience >= 10:
    bonus_percentage = 15
elif experience >= 5:
    bonus_percentage = 10
else:
    bonus_percentage = 5

annual_bonus = salary * (bonus_percentage / 100)

print(f"\nEmployee: {name}")
print(f"Department: {department}")
print(f"Annual Salary: ${salary:,.2f}")
print(f"Experience: {experience} years")
print(f"Bonus ({bonus_percentage}%): ${annual_bonus:,.2f}")

Method 3 – Use List Comprehension

For collecting multiple similar inputs efficiently, I use list comprehension. This approach is perfect when you need the same type of input multiple times.

Here’s how I implement it for a sales tracking system:

# Sales data collection using list comprehension
print("Weekly Sales Tracker")
print("=" * 25)

days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

# Collecting daily sales using list comprehension
daily_sales = [float(input(f"Enter sales for {day}: $")) for day in days]

# Calculating statistics
total_sales = sum(daily_sales)
average_daily_sales = total_sales / len(daily_sales)
best_day_index = daily_sales.index(max(daily_sales))
worst_day_index = daily_sales.index(min(daily_sales))

# Displaying results
print("\n" + "=" * 40)
print("WEEKLY SALES REPORT")
print("=" * 40)

for i, day in enumerate(days):
    print(f"{day:<12}: ${daily_sales[i]:>8.2f}")

print("-" * 40)
print(f"{'Total Sales':<12}: ${total_sales:>8.2f}")
print(f"{'Average':<12}: ${average_daily_sales:>8.2f}")
print(f"{'Best Day':<12}: {days[best_day_index]} (${max(daily_sales):.2f})")
print(f"{'Worst Day':<12}: {days[worst_day_index]} (${min(daily_sales):.2f})")

I executed the above example code and added the screenshot below.

python prompt user for input

Here’s another example for collecting monthly expenses:

# Monthly expense tracker
expense_categories = ["Housing", "Food", "Transportation", "Healthcare", "Entertainment", "Utilities"]

print("Monthly Budget Tracker")
print("-" * 25)
print("Enter your monthly expenses for each category:")

# Using list comprehension to collect expenses
monthly_expenses = [float(input(f"{category}: $")) for category in expense_categories]

# Creating expense dictionary
expense_dict = dict(zip(expense_categories, monthly_expenses))

# Analysis
total_expenses = sum(monthly_expenses)
highest_expense_category = max(expense_dict, key=expense_dict.get)
lowest_expense_category = min(expense_dict, key=expense_dict.get)

# Display results
print("\n" + "=" * 35)
print("MONTHLY EXPENSE BREAKDOWN")
print("=" * 35)

for category, amount in expense_dict.items():
    percentage = (amount / total_expenses) * 100
    print(f"{category:<15}: ${amount:>8.2f} ({percentage:>5.1f}%)")

print("-" * 35)
print(f"{'TOTAL':<15}: ${total_expenses:>8.2f}")
print(f"\nHighest: {highest_expense_category} (${expense_dict[highest_expense_category]:.2f})")
print(f"Lowest: {lowest_expense_category} (${expense_dict[lowest_expense_category]:.2f})")

Method 4 – Use a Loop for Dynamic Input Collection

When you don’t know in advance how many inputs you’ll need, loops are essential. I use this approach frequently in applications where users need to add variable amounts of data.

Here’s an inventory management example:

# Dynamic inventory management system
print("Inventory Management System")
print("=" * 30)

inventory = {}
total_value = 0

print("Enter product information (press 'quit' when done)")
print("Format for each product: Name Quantity UnitPrice")

while True:
    user_input = input("\nEnter product details (or 'quit' to finish): ")

    if user_input.lower() == 'quit':
        break

    try:
        # Split input and validate
        parts = user_input.split()
        if len(parts) != 3:
            print("Please enter: ProductName Quantity UnitPrice")
            continue

        product_name = parts[0]
        quantity = int(parts[1])
        unit_price = float(parts[2])

        # Calculate total value for this product
        product_value = quantity * unit_price

        # Add to inventory
        inventory[product_name] = {
            'quantity': quantity,
            'unit_price': unit_price,
            'total_value': product_value
        }

        total_value += product_value
        print(f"Added: {product_name} - {quantity} units @ ${unit_price:.2f} each")

    except ValueError:
        print("Invalid input! Please enter numbers for quantity and price.")
    except IndexError:
        print("Please provide all three values: ProductName Quantity UnitPrice")

# Display inventory report
if inventory:
    print("\n" + "=" * 60)
    print("INVENTORY REPORT")
    print("=" * 60)
    print(f"{'Product':<15} {'Qty':<8} {'Unit Price':<12} {'Total Value':<12}")
    print("-" * 60)

    for product, details in inventory.items():
        print(f"{product:<15} {details['quantity']:<8} "
              f"${details['unit_price']:<11.2f} ${details['total_value']:<11.2f}")

    print("-" * 60)
    print(f"{'TOTAL INVENTORY VALUE':<47} ${total_value:<11.2f}")
    print("=" * 60)
else:
    print("No products added to inventory.")

This method efficiently handles unknown quantities of input, making it ideal for flexible, user-driven data collection in real-world applications

After working with Python for over a decade, I’ve found that choosing the right input method depends entirely on your specific use case. For simple, fixed inputs, multiple input() functions work perfectly. When dealing with related data, split() offers efficiency and cleaner code.

List comprehension shines when you need multiple similar inputs, while loops provide the flexibility for dynamic data collection. For complex applications requiring validation and error handling, custom functions are indispensable.

You may read:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.