Learn to Code via Tutorials on Repl.it!

← Back to all posts
Learn to code Python! Part 3: For and While!
[deleted]

Welcome back to Part 3 of my Python tutorial here on replit. Yes, this is the third one today but school is boring so here I am doing this. In the last tutorial we learnt about if, elif, and else. These are pretty much the most important thing in python ever.

So head on over to your code and look at elif func_select == 2:. We are going to be deleting accounts so we need to get information from the user about what account they want deleted. So first add this code inside that elif statement.

Next we are going to iterate through the list accounts. What is iterating says the padawan at the front, well iterating is looping. If I was to iterate through a string "Hello World", then I would be looping through each character of that string once. We can do this with a for loop, I will show you another type of loop in a second.

For Loop

A for loop works by iterating through each character in a string, or each item in a list. So what we want to do is iterate through each item in a list to find the specific account we will be deleting. So copy this code into the file.

So this is a for loop, it iterates through the thing it's being told to which in this case is accounts. You see items up there? Well items is a variable which is equal to the item or character that you are currently iterating through. So if items is equal to the account the person wants to delete then, remove items.

So, what if they capitalise the account wrong? Good question, we need to go up to if func_select == 1: and change something in here. So we can turn the account into all lowercase letters so that it is easier to find the correct account.

This turns all the characters into lowercase letters, we can change lower to upper to make them uppercase. Now do the same in elif func_select == 2:, then change the for loop accordingly, I will let you do that.

When testing this, make sure to add at 1 least value to the accounts and balance list because when adding an account the code itself won't update

And you are now done the account deletion! Congrats!

While Loop

Here is that other loop I was talking about. It is called a while loop, it does the same thing over and over until the condition is false.

So it's pretty simple, we can make it say hello world 5 times.

This will print "Hello World" 5 times. Now <= means less than or equal to, you can do the same with >. See i = i + 1? This is what escapes the while loop, it adds 1 to i each time it loops through, so when i is > 5 it will stop. Now I challenge you to make a while loop that counts forever. I will show you how to do it in Part 4 if you can't do it. Make sure to comment below with your code for the counter.

That concludes Part 3 of my Python tutorial, I hope you enjoyed yourself, have fun and good coding!

Cheers,
ChickenTendys
Part 1
Part 2

Voters
Arthif
Pcat1
Comments
hotnewtop
Johnjames14

I am trying to use this multiple input controlled source for POLY model and to get exact dimension. Using https://www.edugeeksclub.com/pay-for-research-paper/ is one of the best experience and I think it's a unique service for those students who want to improve their writing skills.

lawwriting

Perfect place to learn python and other programming languages. definitely best writing team and their expertise in their areas of study. Our services are law essay writing services UK, dissertation help, coursework help, assignment help online, etc. If you want to take do my assignment services in UK.
https://www.lawwriting.co.uk/

pressure3636
pressure3636

Perfect place to learn python and other languages https://pressurewasherelite.co.uk/

KaleemSeoBookma

http://judahdtgr25814.pages10.com
http://jeffreycujv36036.ampblogs.com
http://griffineymy47137.onesmablog.com
http://cashjmak93692.blogocial.com
http://cesarrerb59258.blogolize.com
http://andyymyj92692.tribunablog.com
http://beaucsrk04815.shotblogs.com
http://emilianohpra21932.blogminds.com
http://zionipsq01381.blogzet.com
http://claytonpiwi93692.bloguetechno.com
http://troydveg16037.suomiblog.com
http://devinvjxj93703.thezenweb.com
http://dallasngvh81470.tinyblogging.com
http://franciscodfao55665.pointblog.net
http://alexiswocn14703.full-design.com
https://johnathanbobn04703.blog5.net
http://caidenngug81470.ampedpages.com
https://remingtoncpbm04703.affiliatblogger.com
https://ricardongvj92591.fitnell.com
https://finnsriy83604.diowebhost.com
http://edwinwlxi82481.blogdigy.com
http://devinpiwh81481.mybjjblog.com
https://johnnyduiu36936.bluxeblog.com
https://brooksocpz59258.blogs-service.com
http://beckettywph67655.tblogz.com
http://alexisuyyj16150.canariblogs.com
http://angelogeak77531.uzblog.net
https://zionnjcf42164.qowap.com
https://mylesrlxz59136.jiliblog.com
https://landenoelh86393.getblogs.net
https://jaidenfvit36925.dsiblogger.com
https://lukastdal53186.ka-blogs.com
https://zionmylv36926.aioblogs.com
https://josueatgs25925.timeblog.net
https://elliotanyk92692.xzblogs.com
https://colliniroi22015.free-blogz.com
http://raymondkeuh92604.isblog.net
https://riverwbkl77726.collectblogs.com
http://collinrwwr26815.blogdon.net
https://israelcjon13444.blogofoto.com
http://johnnytlzj92581.blogkoo.com
http://ricardocwkw47036.alltdesign.com
http://manuelpdpb69258.amoblog.com
http://cashxrht25815.total-blog.com
http://juliuswlxi82582.blog-gold.com
http://cruzkfwk03714.atualblog.com
http://israelpizl03603.blog-a-story.com
http://charliefuht36936.blogacep.com
http://dominickfrdo04703.blogadvize.com
http://trentonnwaw35567.bloggerbags.com
http://alexiseypa69369.bloggerswise.com
http://beckettdwlx48147.bloggosite.com
http://cesargxkw37036.blogoscience.com
http://juliuskjal78655.blogrelation.com
http://keegantoyg39730.blogproducer.com
http://manuelzobn04703.blogrenanda.com
http://cashleug82503.blogsidea.com
http://waylonlfvi93692.blogthisbiz.com
http://eduardovtmx58158.blue-blogs.com
http://trevorlusm89988.csublogs.com
http://connerehiz34433.dailyhitblog.com
http://marioctkx59260.develop-blog.com
http://judahlylv37036.is-blog.com
http://beaueteq15815.livebloggs.com
http://emilioxlzm04703.loginblogin.com
http://jeffreypdrc70471.mdkblog.com
http://keeganhvlf29630.newbigblog.com
http://cesarujwh81471.mybuzzblog.com
http://elliotjzny59258.thenerdsblog.com
http://franciscouqfp15814.theobloggers.com
http://johnnywqgt37148.topbloghub.com
http://rowanqjzl03692.ttblogs.com
http://jeffreywzpa60269.vblogetin.com
http://paxtonnizn05825.win-blog.com
http://ricardotlbn04703.worldblogged.com
http://archeruhue60360.yomoblog.com
https://waylonnuup01112.bloginwi.com
https://damienodrd60369.blogzag.com
https://dominickcpcn14703.jaiblogs.com
https://trentongruc81468.blogsumer.com
https://raymondtmko15815.jts-blog.com
https://jaidenkzmx58147.blogaritma.com
https://elliotthvku37036.shoutmyblog.com
https://connergcdd71470.iyublog.com
https://angelogbrd71482.blogdiloz.com
https://troyreqb59259.verybigblog.com
https://louisrncp14714.activosblog.com
https://daltonncpb60359.p2blogs.com
https://caidenwtjw48150.bloggactivo.com
https://judahvqgs37047.theblogfairy.com
https://rowanhuhs25925.vidublog.com
https://johnnyvjug71470.oblogation.com
https://gunnerysiu36026.gynoblog.com
https://troywgcy56740.angelinsblog.com
https://trentonzobm04703.bloggadores.com
https://zanderwpdp14703.thekatyblog.com
https://johnathanqkyj92581.blogspothub.com
https://rafaelxlyi93693.blogdemls.com
https://edgarbobm03703.idblogmaker.com
https://brooksncqc60259.ageeksblog.com
https://rylanftiu36935.blogunteer.com
https://archerxkxi81470.life3dblog.com
https://zionmznz59259.therainblog.com
https://mylesdreq15814.ltfblog.com
https://elliottcvju36926.thechapblog.com
https://connerryqr08016.blogmazing.com
https://judahiuhs26925.losblogos.com
https://rafaeltfsc60369.blogsvirals.com
https://angeloapct67047.glifeblog.com
https://rylanyvlv08108.estate-blog.com
https://troytfte60369.prublogger.com
https://louisgkzk55434.bloguerosa.com
https://sethpkam14703.daneblogger.com
https://juliuskbqc60369.blogozz.com
https://keegandsfq25815.popup-blog.com
https://knoxmvij97778.ssnblog.com
http://andrecreq25825.aboutyoublog.com
https://manuelcrgs26925.bloggazzo.com
http://johnathanhteb88766.blog5star.com
http://emilianouqgw60269.blogdun.com
http://tysonsmbo15815.bloggactif.com
http://cruzfzob60360.blogginaway.com
http://israelatkw47147.blogolenta.com
http://spencerzsyr48141.blogripley.com
http://zionvjnb76284.blogsuperapp.com
http://marcoowvs88782.dgbloggers.com
http://andyuhuf72581.frewwebs.com
http://johnnywrht36935.dreamyblogs.com
http://collinboco14703.howeweb.com
http://dominickxkwi82581.idblogz.com
http://lorenzogzny58148.izrablog.com
http://sethbvmz60482.kylieblog.com
http://martinwriv48159.slypage.com
http://spenceroerc69369.luwebs.com
http://manuelrfse71370.webbuzzfeed.com
http://jasperhwlv37036.webdesign96.com
http://waylonlyku37036.59bloggers.com
http://rowangtfq15814.bligblogging.com
http://brookskwju36026.actoblog.com
http://hectorbvky47147.blog-mall.com
http://zanderwrmx48147.blogofchange.com
http://simonsnam03692.blogs100.com
http://jaidenslam03693.spintheblog.com
http://jaidenjwjv37036.dailyblogzz.com
http://arthurlcqc60369.blogvivi.com
http://rylanjykv37036.bloginder.com
http://simonguis26925.blogdal.com
http://keeganguhs26926.newsbloger.com
http://deanpsyn15814.get-blogging.com
http://marcovjvg71481.targetblogs.com
https://paxtonrfsd69369.activoblog.com
https://judahatiu37936.blogoxo.com
https://troytguf71470.elbloglibre.com
https://paxtonsgvg81471.blazingblog.com
https://raymondvgmq15790.ja-blog.com
https://sethjxju37036.blogscribble.com
https://deandqcm04703.creacionblog.com
https://deanztit37935.tusblogos.com
https://devinmftf71470.blogchaat.com
https://andrelapb69258.dm-blog.com
https://simonboak93692.blogdeazar.com
https://rafaelvivg81471.eedblog.com
https://griffinqdrb59259.blog2freedom.com
https://lorenzolcqe71471.bloggip.com
https://chancecjjn26754.qodsblog.com
https://edgaraozl93692.blogpayz.com
https://augustndmi13592.liberty-blog.com
https://dallasehfw12210.buyoutblog.com
https://codyaejm24331.blogitright.com
https://remingtonbqdn04703.blog-eye.com
https://andreseksu35888.blogunok.com
https://shanecxmy59258.blogdosaga.com
https://lukasjanz59259.azzablog.com
https://jaidencear00990.snack-blog.com
https://devinohvg82470.anchor-blog.com
https://claytonocpa59259.blogpixi.com
https://holdenymal93692.wssblogs.com
https://johnathanwpdp14703.blogdanica.com
https://dominickuvlr83720.bloggerchest.com
https://augustynal03693.tkzblog.com
https://marcoukyj93693.like-blogs.com
https://elliottoboz58258.blog-kids.com
https://connerswrh55443.ziblogs.com
https://josueggdw23444.answerblogs.com
https://elliottxpun73283.nizarblog.com
https://israeltpfs26936.tokka-blog.com
http://laneuhuf71471.ambien-blog.com
https://josuezggc56789.boyblogguide.com
https://troyvkxj93692.goabroadblog.com
https://beckettsbby34555.activablog.com
https://claytonctcr41656.blog-ezine.com
https://louistgsv09449.weblogco.com
https://caidenuhvf71471.ourcodeblog.com
https://holdenrdbb66679.techionblog.com
https://charlielcqc69359.fare-blog.com
https://cristianaobl93692.onzeblog.com
https://trentonefdp45734.sharebyblog.com

Lucie254
hanry

I want to learn python language because I am very passionate to learn new languages then my dream was to create a website with python that why I am taking help from onlinecoursework.co.uk because they do my coursework for me and they also help me to learn new languages.

kimchiimg

I am really impressed with your article!
resize image

JamesOwens1

When I was building an e-commerce custom site, I had to spend a lot of time on the php and javascrip frameworks, and believe it or not, my first e-commerce project had an incredible custom css design merely because of this flaw of knowledge that website owners post on their blogs. write my assignment for me

ExpressMinicabs

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here!
https://www.expresscouriercars.co.uk/

alisahwilson

AllAssignmentHelp.co.uk offers the best academic services in the UK and all across the world. With our online assignment help, you can easily top your college and university. We have the best writing team and their expertise in their areas of study. Our services are essay writing, case study, dissertation help, coursework help, homework help online, academic study help, etc. If you want to take do my assignment service, hire our assignment writer to help experts today. you can contact us anytime and buy assignment from experts at a very genuine cost.

lawessay

One of my friends can give this post link and ask me to learn php from that website; I'm a newbie, so if anyone can advise me from A to Z on where I should start, that would be great. I have to handle my site essay help from now on because my friend is on vacation.

leschrapid

A really amazing article. I love it so much!. - . 1v1 lol slope unblocked

arnoldmiler

With over ten years of experience servicing clients nationally, we feel we are the Top Digital Marketing Company. We use digital platforms to share your story and bind your brand to clients, boosting your company and assisting you in reaching your full online potential.

JenDavis1

Hi! People, I’m new to coffee making, so maybe someone more experienced could give me a tip. What are the best beans for cappuccino? It’s my GF’s favorite drink, so I want to learn how to make it perfect. https://coffeelikeapro.com/coffee-beans/best-coffee-beans-for-cappuccino

adamsmith87

Add Ivacy google chrome best vpn extension on your google chrome browser and connect to any of their 3200+ servers and protect your online presence.

EmmaDiaz123

Want to know what students say about WritePaperFor.me? It is a good idea. I like these WritePaperFor.me reviews, they contained fresh info and facts about this service.
https://essayservices.review/reviews/writepaperforme-review

sylvia99w

Dunno how to jumpstart your essay? Here you’ll get info on how to craft an A-grade assignment with ease! https://collegehomeworktips.com/how-to-write-a-critical-essay-top-guidelines-and-recommendations/ The work will be done in the blink of an eye!

TomBrown3608

The second time I got help in essay writing, and they met my short deadline again. I'm sure Speedypaper has professional writers, and I will definitely continue to use this site.

Jasminmark

Even when clients tell writers online that they are ready to pay to write my assignment, they rarely manage to get the kind of excellence they are looking for. This is where they need to consider contacting a reliable service provider like Crowd Content for expert assistance.

jenniferaniston

For loops can also be used for a set of other things, not just numbers. Is it true? Source: pay for essay UK of UK Writing Experts.

Adrian466

Recently I have discovered the Python is an easy language to learn and understand the basics of coding, How coding works for http://www.college-universities.com/articles-guide-how-to-write-winning-college-masters-thesis.php and there are different software available to code on. I am taking the python classes from the online source due to the covid. I am it will help me to discover more coding platform.

Bookie0

Hey,

You should concatenate all your tutorials series into one big tutorial instead of posting several ones! :D