

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does * operator work on list in Python?
The star(*) operator unpacks the sequence/collection into positional arguments. So if you have a list and want to pass the items of that list as arguments for each position as they are there in the list, instead of indexing each element individually, you could just use the * operator.
example
def multiply(a, b): return a * b values = [1, 2] print(multiply(*values))
This will unpack the list so that it actually executes as −
print(multiply(1, 2))
Output
This will give the output −
2
- Related Questions & Answers
- How does in operator work on list in Python?
- How does concatenation operator work on list in Python?
- How does repetition operator work on list in Python?
- How does del operator work on list in Python?
- How does concatenation operator work on tuple in Python?
- How does the * operator work on a tuple in Python?
- How does the repetition operator work on a tuple in Python?
- How does the del operator work on a tuple in Python?
- How does the 'in' operator work on a tuple in Python?
- JavaScript : Why does % operator work on strings? - (Type Coercion)
- How does the Comma Operator work in C++
- How does a list work in Java?
- How does comparison operator work with date values in MySQL?
- How does Python while loop work?
- How does mkdir -p work in Python?
Advertisements