create account

RE: Learn Basic Python Programming EP.3. - Logic & Loops by ragequit

View this thread on: hive.blogpeakd.comecency.com

Viewing a response to: @profitgenerator/learn-basic-python-programming-ep-3-logic-and-loops

· @ragequit ·
$0.18
Sweet!

The way I like to think about the for loop in python is that it's actually the foreach from other languages. Since you can achieve with the while loop anything you could with the classical for loop why not shorten the foreach and call it a day!
👍  
properties (23)
authorragequit
permlinkre-profitgenerator-learn-basic-python-programming-ep-3-logic-and-loops-20170630t131358289z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-06-30 13:14:00
last_update2017-06-30 13:14:00
depth1
children2
last_payout2017-07-07 13:14:00
cashout_time1969-12-31 23:59:59
total_payout_value0.174 HBD
curator_payout_value0.003 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length252
author_reputation84,968,448,410
root_title"Learn Basic Python Programming EP.3. - Logic & Loops"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id6,759,315
net_rshares20,415,984,018
author_curate_reward""
vote details (1)
@profitgenerator ·
I didnt quite understood what is the difference between foreach and for, I believe it can iterate other things too not just numbers.

Also keep in mind that I have like medium knowledge about python, I have not much experience with using classes and other objects , I have to learn more about those. But I will touch functions and other basic things in this tutorial.
properties (22)
authorprofitgenerator
permlinkre-ragequit-re-profitgenerator-learn-basic-python-programming-ep-3-logic-and-loops-20170630t131616200z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-06-30 13:16:36
last_update2017-06-30 13:16:36
depth2
children1
last_payout2017-07-07 13:16:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length367
author_reputation68,549,319,463,075
root_title"Learn Basic Python Programming EP.3. - Logic & Loops"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id6,759,576
net_rshares0
@ragequit ·
Explaining to others is a great way of making sure you understand something, it's a good thing to do once you feel like you master something. It also helps you figure out what you don't understand that well and look over it again.

The idea is that Python doesn't have a foreach syntax like other languages, instead the for loop works like a foreach would. If you have no idea what I'm talking about don't stress it, it's just a tip for whoever is coming from another language that has the classic for loop
>for (element = 0; element < list; element++)

 to remember that python's <strong>for</strong> is actually a foreach 
>for~~each~~ element in list:
___do stuff
properties (22)
authorragequit
permlinkre-profitgenerator-re-ragequit-re-profitgenerator-learn-basic-python-programming-ep-3-logic-and-loops-20170630t133146213z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-06-30 13:31:48
last_update2017-06-30 13:31:48
depth3
children0
last_payout2017-07-07 13:31:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length666
author_reputation84,968,448,410
root_title"Learn Basic Python Programming EP.3. - Logic & Loops"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id6,761,226
net_rshares0