Skip to content
Sign upLog in
← Back to Community

Learn to code Python! Part 3: For and While!

Profile icon
[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.

accDelete = input("account: ")

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.

for items in accounts: if items == accDelete: accounts.remove(items)

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.

accCreateLow = accCreate.lower()

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.

while condition: body

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

i = 0 while i <= 6: print("Hello World") i = i + 1

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
Profile icon
Arthif
Profile icon
Pcat1
Comments
hotnewtop
Profile icon
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.

Profile icon
lucreziaapaola

The only place where all the students can receive 100% quality content is buy-custom-writings.com There you can get cheap custom writings too.

Profile icon
HolidayMaker

If you are looking for guest posts then you must visit us We have lots of articles related to tourism and travel information, the latest updates on tourism, and accounting and financial information on this website. SO U Must Visit Us: Tourist Places to Visit in India

Profile icon
HolidayMaker

Great post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here. Visit Us: India Travel Blog

Profile icon
ambermillington

You are a student who is looking for a writing service where you can buy capstone project online? I can help you! Visit this website essayscreator.com

Profile icon
HolidayMaker

Grab the best deal on Chardham Yatra by Helicopter Tour Package and explore Kedarnath, Badrinath, Yamunotri, and Gangotri at the most pocket-friendly budget. Visit Us: Chardham Yatra by Helicopter

Profile icon
HolidayMaker

Your article is interesting and well-written; the information is useful and grabs people's attention. North East Tour Packages

Profile icon
MichelleRichers

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. MCCQE

Profile icon
samanthadavis40

Thanks for sharing the useful information with us. From my side I want to recommend a writing service where you can https://essays-writer.net/articles-for-sale/ buy blog articles.

Profile icon
AlbertJiles

While some expensive bassinets are worth buying, consider how they are durable and last for a long time.

Profile icon
AlbertJiles

Thank you for your post. To watch Slice TV in the US, you need to follow the Link

Profile icon
maheshsaxena960
Profile icon
lunabeth

Canon is one of the primitive choices of the users when it comes to opting for a perfect printing option The canon printer is well-known for delivering high-quality printing outputs. https://www.ijstartcan-on.org/

Profile icon
jacktoco

Thank you for the detailed post. Lovely.
https://www.amphasisdesign.com

Profile icon
sukanobi

Thank you for your post. I have read through several similar topics! However, your article gave me a very special impression, unlike other articles. I hope you continue to have valuable articles like this or more to share with everyone! crossword puzzles

Profile icon
RebeccaWills

"Thank you so much for sharing all of this fantastic information and how-to's!!!!" Thank you very much! Our expert british essay writer is Here, Kindly share your query and find out the best phyton answers, click the link to know for details and get 20%OFF.

Profile icon
FlaviaDerby

"Thank you so much for sharing all of this fantastic information and how-to's!!!!" Thank you very much! Our expert dissertation help service Here, Kindly share your query and find out the best phyton answers, click the link to know for details and get 20%OFF.

Profile icon
Charlotte1231

hi am thanks for sharing this code with us I am making now own games like. https://slope-game.com/slope-unblocked, https://badicecreamgame.com/we-become-what-we-behold

Profile icon
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/

Profile icon
pressure3636
Profile icon
pressure3636

Perfect place to learn about projectors and there information on sports bar https://projectorsplace.com/best-projector-for-sports-bar/

Profile icon
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

Profile icon
Lucie254
Thanks for sharing this wonderful post. <a href="https://www.google.com">google</a>
Profile icon
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.

Profile icon
kimchiimg

I am really impressed with your article!
resize image

Profile icon
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

Profile icon
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/

Profile icon
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.

Profile icon
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.

Profile icon
leschrapid

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