Learn Python LIST COMPREHENSIONS in 10 minutes! 📃

preview_player
Показать описание
# List comprehension = A concise way to create lists in Python
# Compact and easier to read than traditional loops
# [expression for value in iterable if condition]

doubles = [x * 2 for x in range(1, 11)]
triples = [y * 3 for y in range(1, 11)]
squares = [z * z for z in range(1, 11)]

fruits = ["apple", "orange", "banana", "coconut"]
fruit_chars = [fruit[0] for fruit in fruits]
Рекомендации по теме
Комментарии
Автор

# List comprehension = A concise way to create lists in Python
# Compact and easier to read than traditional loops
# [expression for value in iterable if condition]

doubles = [x * 2 for x in range(1, 11)]
triples = [y * 3 for y in range(1, 11)]
squares = [z * z for z in range(1, 11)]

fruits = ["apple", "orange", "banana", "coconut"]
uppercase_words = [fruit.upper() for fruit in fruits]
fruit_chars = [fruit[0] for fruit in fruits]

numbers = [1, -2, 3, -4, 5, -6, 8, -7]
positive_numbers = [x for x in numbers if x >= 0]
negative_numbers = [x for x in numbers if x < 0]
even_numbers = [x for x in numbers if x % 2 == 0]
odd_numbers = [x for x in numbers if x % 2 == 1]

grades = [85, 42, 79, 90, 56, 61, 30]
passing_grades = [grade for grade in grades if grade >= 60]

BroCodez
Автор

I am from India what a melodious voice u have

ranjeetprasad
Автор

Like the 3rd video I watch about it, and I finally understood it 2 mins in, thanks a lot for being this great!

oseaniic
Автор

This dude is the definition of Gigachad

JuanTheone
Автор

Sir please continue and complete the react course

technicalswag
Автор

You are both a good teacher and a good person,
i think that because you got 6000 usd for a good cause!

Ctrl-Z-Renders
Автор

pls make a video about explaining grid in css🙏🙏

Norro_o
Автор

I wonder if bro making these videos, recently . cause after making React tutorials he wants to take some time off. if it is we are all happy that you back. and we hope to learn Next.js from you.

xzex
Автор

why is he redoing these python videos? he already had made a video on list comprehensions

exyoris
Автор

can u pls mmake a video about numpy arrays

oeyqpmd
Автор

I can just say you are smarter than chat gpt !

titangamer
Автор

Bro Code teaching me more in 10 minutes than my IT teacher teaching me the same material in 2 weeks😭

aj_the_cutiepatootie
Автор

When I try to run the script at 4:54, I keep getting this AttributeError and exit code 1. What happened?

NinjaDude_YT