Skip to content

Commit b8386ed

Browse files
✨ std_lib: combine iterables
1 parent 22a36d9 commit b8386ed

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

standard_lib/README.md

+1
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

+8
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)