Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b8386ed

Browse filesBrowse files
✨ std_lib: combine iterables
1 parent 22a36d9 commit b8386ed
Copy full SHA for b8386ed

File tree

2 files changed

+9
-0
lines changed
Filter options

2 files changed

+9
-0
lines changed

‎standard_lib/README.md

Copy file name to clipboardExpand all lines: standard_lib/README.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ A collection of useful snippets using only the standard library.
1616
| chained_assignments | Assign a value to multiple variables using chained assignments |
1717
| chained_comparison | Chain comparisons to have more math-like comparisons |
1818
| check_pattern | Check for multiple string patterns |
19+
| combine_iterables | Combine two iterables using `zip()` |
1920
| compare_strings | Use `difflib.SequenceMatcher` to compare strings |
2021
| count_thresholds | Count the number of elements between certain thresholds |
2122
| crazy_dict_expression | The craziest dictionary expression ever seen |

‎standard_lib/combine_iterables.py

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
grades = [1, 2, 3, 4, 5]
2+
phrases = ["very good", "good", "okay", "at least not failed", "failed"]
3+
4+
combined = list(zip(grades, phrases))
5+
print(combined)
6+
7+
for grade, phrase in combined:
8+
print(grade, phrase)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.