0% found this document useful (0 votes)
47 views6 pages

Taking User Input in Python

The document discusses taking user input in Python. It explains how to use the input() function to accept a single value of user input. It also describes how to take multiple inputs using the split() method, which breaks the input into a list based on a specified separator, or whitespace by default. Examples are provided for taking multiple inputs without and with a specified separator, and using the * operator to unpack the resulting list into separate variables.

Uploaded by

kunal patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
47 views6 pages

Taking User Input in Python

The document discusses taking user input in Python. It explains how to use the input() function to accept a single value of user input. It also describes how to take multiple inputs using the split() method, which breaks the input into a list based on a specified separator, or whitespace by default. Examples are provided for taking multiple inputs without and with a specified separator, and using the * operator to unpack the resulting list into separate variables.

Uploaded by

kunal patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 6

Taking

User Input
In Python

Ali Moustafa
@ali-moustafa2000
Inputting One Value
In Python, you can use the "input()" function to
accept user input.
Here's an example of how to take input for one
value:

@ali-moustafa2000
Inputting Multiple Values

You can also take input for multiple values in


Python Using the "split()" method.

This method helps in getting multiple inputs from


users. It breaks the given input by the specified
separator.

If a separator is not provided then any white space


is a separator.

@ali-moustafa2000
Inputting Multiple Values

Example If a separator is "not provided"

@ali-moustafa2000
Inputting Multiple Values

Example If a separator is "provided"

Output will be priented in a list so If you want to


unpack the list of numbers and use them as
separate variables, you can use the "*" operator.
For example:

@ali-moustafa2000
Inputting Multiple Values

Using "*" to unpack the list

@ali-moustafa2000

You might also like