Skip to content

Instantly share code, notes, and snippets.

View thecodix's full-sized avatar

Alfredo Romeu thecodix

View GitHub Profile
@thecodix
thecodix / list_comprehension_practice.py
Created November 4, 2021 15:11 — forked from ryanorsinger/list_comprehension_practice.py
17 List Comprehension Exercises
# 17 list comprehension problems in python
fruits = ['mango', 'kiwi', 'strawberry', 'guava', 'pineapple', 'mandarin orange']
numbers = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 17, 19, 23, 256, -8, -4, -2, 5, -9]
# Example for loop solution to add 1 to each number in the list
numbers_plus_one = []
for number in numbers:
numbers_plus_one.append(number + 1)