Skip to content

Commit a98538d

Browse files
authored
Update README.md
1 parent 130d5ea commit a98538d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,23 @@ Python is more like java and bit cumbersome, but it leads to a better design. Py
380380

381381
There are 2 optional clauses used in try...except statements: 1. else clause: It is useful for code that must be executed when the try block doesn't create any exception2. finally clause:Its is useful for code that must be executed irrespective of whether an exception is generated or not.
382382

383+
384+
#### Is it possible to assign multiple var to values in list?
385+
A: The multiple assignment trick is a shortcut that lets you assign multiple variables with the values in a list in one line of code. So instead of doing this:
386+
```
387+
>>> cat = ['fat', 'orange', 'loud']
388+
>>> size = cat[0]
389+
>>> color = cat[1]
390+
>>> disposition = cat[2]
391+
```
392+
393+
Do this:
394+
```
395+
cat = ['fat', 'orange', 'loud']
396+
size, color, disposition = cat
397+
```
398+
399+
383400
#### What is List Comprehensions feature of Python used for?
384401

385402
List comprehensions help to create and manage lists in a simpler and clearer way than using map(), filter() and lambda. Each list comprehension

0 commit comments

Comments
 (0)