Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)

preview_player
Показать описание
This is the 9th video in my python programming tutorial series. Today I talk about how to iterate through a list by item using a for loop. This is a continuation from my 6th video where I talk about basic for loops.

As always please LIKE and SUBSCRIBE for more content daily!

Video Tags:
python,python tutorial,python language,python full course,python course,learn python,learn python programming,python tutorial for beginners,python tutorial 2018,python programming tutorial,python programming language,software development,programming tutorial,tech with tim
Рекомендации по теме
Комментарии
Автор

The plural of strawberry is strawberries!

mikestombraidervids
Автор

U are really good explaining complex topics, thanks 4 share with us!

giocarp
Автор

Thanks for making this, I really appreciate it!

hackercop
Автор

something that I've been trying to gain a concrete explanation of as I learn the introduction to python and programming in general is how variables are kind of implicitly defined when, for example, you're making the for loop here. While 'fruits' is assigned a value (a list in this case) on the first line, 'fruit' is assigned on the fly within the for loop script. I thought that it's only locally defined, but then I see that subsequent to the for loop, printing 'fruit' prints the last item in the list? Any commentary would help me understand this better.

TheDorfan
Автор

Your videos are so straight to the point. Watching in 1.5x speed.

MozwGamer
Автор

1. To print only the last element of the list you can use:
print(fruits[-1])
2. To use for loop without len() you can use:
for i in fruits[::]:
print(i)

yahianad
Автор

I get syntax error on the first else:

fruits = ['apples', 'pears', 'strawberry', 3, 8, 90 ]

for fruit in fruits:
if fruit == 'pears':
print(fruit)
else:
print('not pears')
for x in range(0, 6):
if fruits[x] == 'pears':
print(fruit[x])
else:
print('not a pear')

CryptoHuntersGuild
Автор

This video has no dislikes. Let's keep it that way shall we?

produji
Автор

I'm having a little trouble distinguishing squared brackets from parenthesis, you need the square brackets in the initial list right?

kellycoyne
Автор

I just want to print out the strings but not integers in the list, so I tried this:


fruits = ['apple', 'orange', 'banana', 12, 15, 18]

for fruit in fruits:
if fruit != type(int):
print(fruit)
else:
print('not a fruit')

However, it just printed all 6 things out, may I ask what is the problem? Thanks

tomchan
Автор

Can u say for fruits in fruits?
instead of for fruit in fruits

wongkingshun
Автор

fruits = ['apples', 'pears', 'strawberrys']
fruits[2] = 'strawberries'
print(fruits)
I just feel like I'm a wizard 🤣

petrex
Автор

Nice video
Watched at 2x
Meet you in next one

eswarspython
Автор

I watched this video like a month ago and i just realized we're doing "fruit loops" lol

hydrolysistricking
Автор

i think u typed fruit, not fruits by accident.

stephanzoes
join shbcf.ru