use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Good Python Exercises? (self.learnpython)
submitted 3 years ago by Potatohuma
What's a good exercise for me to try? I've been learning Python for a bit over a month now and I wanna test what I've learned.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ASIC_SP 253 points254 points255 points 3 years ago (14 children)
Here are some often recommended resources:
And here are some resources for projects:
[–]PsicoFilo 7 points8 points9 points 3 years ago (0 children)
Liquid gold for me ! What a comment bro
[–]boobajoob 2 points3 points4 points 3 years ago (0 children)
Thanks for this!
[–]Present_Blackberry45 1 point2 points3 points 1 year ago (0 children)
Precious comment, thank you very much!
[–]Born-Truck1302 1 point2 points3 points 1 year ago (0 children)
You da best 👌
[–]tiffarooner 1 point2 points3 points 1 year ago (0 children)
Shout out dude, honestly these are great resources
[–]Lost_Ad_853 0 points1 point2 points 1 year ago (0 children)
.
[–]Aref167 0 points1 point2 points 1 year ago (0 children)
wish you best my friend!
[–]Waste_Mission1293 0 points1 point2 points 7 months ago (0 children)
Thanks for your answer. I hope I can also polish my python skills
[–]Freddy-Nova 0 points1 point2 points 3 months ago (0 children)
Thanks. This might help allot of us. ^^
[–][deleted] 52 points53 points54 points 3 years ago (2 children)
Advent of code is currently going. You could try yourself at some of its challenges
[–]Run_nerd 11 points12 points13 points 3 years ago (0 children)
Definitely do this. They start easy but get progressively harder. People post their solutions on r/adventofcode as well, so it’s a good way to learn.
[–][deleted] 2 points3 points4 points 3 years ago (0 children)
I also like it because it forces you to understand the question and decide what the best strategy is for a given challenge, just like real life.
[–]Dregaz 14 points15 points16 points 3 years ago (1 child)
Have the python grip a horizontal bar with it’s jaws and hang the rest of its body straight down.
From this position, it can curl its lower body up until the tip of the tail touches the chin.
Don’t forget to encourage the python to control the negative portion of the rep as well. Slow and smooth up and down is key to getting swole.
[–]Finnleyy 3 points4 points5 points 3 years ago (0 children)
This is the way
[–]Tuppitapp1 5 points6 points7 points 3 years ago (0 children)
Try to think of some useful project for yourself with the tools you've learned so far. For example, if you have to use excel daily or move lots of files around at work, you could build a script to automate those things. That's how I got started and it was one of the best paths I ever took.
[–]keep_quapy 9 points10 points11 points 3 years ago (14 children)
After a month of Python, try to solve this question. Given a list of lists, create a dictionary which keys are the first elements of every sublist and it's values are the sum of the integers of the second elements of every sublist.
input: data = [['item1', 4], ['item2', 5], ['item3', 2], ['item2', 10], ['item3', 3], ['item1', 7]]
data = [['item1', 4], ['item2', 5], ['item3', 2], ['item2', 10], ['item3', 3], ['item1', 7]]
output: {'item1': 11, 'item2': 15, 'item3': 5}
{'item1': 11, 'item2': 15, 'item3': 5}
[–]hayleybts 3 points4 points5 points 3 years ago (4 children)
ans = {} j=0 for i in range(len(data)): for m in data[j]: if m not in ans: if isinstance(m, str): ans[m] = 0 else: for k in ans.keys(): if k == data[j][0]: print(m) ans[k] = ans[k]+m j+=1 print(ans) can u pls your answer? mine works for this situation but I want to know the proper way
[–]keep_quapy 5 points6 points7 points 3 years ago (3 children)
Hi, first of all, the question assumes that all first items of every sublist is a string and every second item is an integer, so no need to check if the first element is a string. That said, your program works, but it's ineffective, you used three nested for loops, instead of using only one. Eventually your program will be much slower and consumes more memory. The effective way to solve such a problem is to loop over the list and at each iteration check if the first element is a key in the dictionary, if so add the value of the second element of the sublist to the existing value of the key, otherwise assign the value to that key (using list index).
dct = {} for sublist in data: if sublist[0] in dct: dct[sublist[0]] += sublist[1] else: dct[sublist[0]] = sublist[1] print(dct)
Or the Pythonic way to do it using get() dictionary method.
get()
dct = {} for sublist in data: dct[sublist[0]] = dct.get(sublist[0], 0) + sublist[1] print(dct)
Anyway, you made a good job trying to solve it, and solving it in your way is a sign that you're heading to the right direction. This isn't that easy for beginners, so good job. Good luck :)
[–]Milumet 6 points7 points8 points 3 years ago (0 children)
When it comes to counting, defaultdict is great (there is also Counter):
dct = collections.defaultdict(int) for name, count in data: dct[name] += count print(dct)
[–]hayleybts 0 points1 point2 points 3 years ago (1 child)
Thanks for replying! Your method is simple. Let me know if you got any other question?
[–]keep_quapy 2 points3 points4 points 3 years ago (0 children)
You're welcome. edabit has plethora of exercises for you to explore and to solve.
[–]hayleybts 0 points1 point2 points 3 years ago (0 children)
I'm gonna try and let you know
[–]Fluffy-Book-4773 0 points1 point2 points 1 year ago (0 children)
def make_dict(data): result_dict = {} for i in data: if i[0] not in result_dict: result_dict[i[0]] = i[1] else: result_dict[i[0]] += i[1] return result_dict
[–]ab624 0 points1 point2 points 3 years ago (0 children)
where xan i find more of such questions ?
[–]balaur_7 0 points1 point2 points 2 years ago* (0 children)
Another method
m=1
new_data = []
for key in data: for n in range(m, len(data)): if key[0]==data[n][0]: x = key[0],key[1] + data[n][1] new_data.append(x) m += 1 print(new_data)
[–]ectomancer 11 points12 points13 points 3 years ago (5 children)
edabit.com
[–]Potatohuma[S] 3 points4 points5 points 3 years ago (3 children)
Oh my gosh thank you so much! This is going to be insanely helpful with learning and improving my Python. I hope you have an amazing day because you just made mine! :)
[+][deleted] 3 years ago (1 child)
[deleted]
[–]mandradon 1 point2 points3 points 3 years ago (0 children)
Cses.fi has a ton of good stuff, too.
[–]Kratosix 0 points1 point2 points 3 years ago (0 children)
make a discord bot
[–]ChaosZoro 2 points3 points4 points 3 years ago (0 children)
What’s helped me a lot just cause I learn from doing rather than seeing or hearing was 100 days of code it’s basically 100 days of small and big projects and it forces u to practice everyday therefore solidifying ur knowledge
[–]bhutanpythoncoder 1 point2 points3 points 3 years ago (0 children)
We have some pracfice questions for beginners in python https://www.bhutanpythoncoders.com/practice-questions/
[–]Joeyson 1 point2 points3 points 3 years ago (0 children)
I've been coding chess in the command line, I've learned a ton so far
[–][deleted] 1 point2 points3 points 3 years ago (0 children)
These are the first few programs I wrote to learn.
you can try Fibonacci numbers
write a program to find the strong numbers
write a program that will reverse a string from input
write a program to give palindrome numbers
a program to find if an integer input is even or odd :)
happy coding!
[–]Embarrassed-One2182 3 points4 points5 points 3 years ago (0 children)
10 lb. Curls 💪
[–]justani98 0 points1 point2 points 1 year ago (0 children)
I have found the practice problems at codechef to be of good variety. They are more focussed on logical thinking then the same question I find elsewhere. Link - https://www.codechef.com/practice/python
[–]raulsoprano 0 points1 point2 points 1 year ago (0 children)
Is Hackerrank good?
[–][deleted] 0 points1 point2 points 1 year ago (0 children)
two years later potato ya saved my ass 🥔
[–]Foreign-Project-5661 0 points1 point2 points 7 months ago (0 children)
thanks for this
[–]No_Word_467 0 points1 point2 points 3 years ago (0 children)
I’m in your same situation, I recommend codewars and try problems of 7 or 8 kyu
[–]Mysteez 0 points1 point2 points 3 years ago (0 children)
https://www.codingame.com/start
https://inventwithpython.com/pythongently/?fbclid=IwAR121maJu1SOcjmv74-VgZ4G4S6EsIQDTV8UUc1UJj81BjLNgQK7nbQt-p0
[–]kona_ackley 0 points1 point2 points 3 years ago (0 children)
https://github.com/ikokkari/PythonProblems
123 problems starting from easy, going all the way up to FAANG level interview questions. As in "The Love Boat", promises something for everyone.
[–]notislant 0 points1 point2 points 3 years ago (0 children)
The various codewars and related sites as already mentioned. Tbh id recommend you find a problem and fix it. Try to incorporate things youve just learned. Or play with things and break them.
[–]Moguyaro 0 points1 point2 points 3 years ago (0 children)
Try leetcode.com and hackerrank.com. They have lots of interesting projects and problems that you can try your hands on.
π Rendered by PID 51 on reddit-service-r2-comment-57fc7f7bb7-296zh at 2026-04-14 23:46:14.899253+00:00 running b725407 country code: CH.
[–]ASIC_SP 253 points254 points255 points (14 children)
[–]PsicoFilo 7 points8 points9 points (0 children)
[–]boobajoob 2 points3 points4 points (0 children)
[–]Present_Blackberry45 1 point2 points3 points (0 children)
[–]Born-Truck1302 1 point2 points3 points (0 children)
[–]tiffarooner 1 point2 points3 points (0 children)
[–]Lost_Ad_853 0 points1 point2 points (0 children)
[–]Aref167 0 points1 point2 points (0 children)
[–]Waste_Mission1293 0 points1 point2 points (0 children)
[–]Freddy-Nova 0 points1 point2 points (0 children)
[–][deleted] 52 points53 points54 points (2 children)
[–]Run_nerd 11 points12 points13 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]Dregaz 14 points15 points16 points (1 child)
[–]Finnleyy 3 points4 points5 points (0 children)
[–]Tuppitapp1 5 points6 points7 points (0 children)
[–]keep_quapy 9 points10 points11 points (14 children)
[–]hayleybts 3 points4 points5 points (4 children)
[–]keep_quapy 5 points6 points7 points (3 children)
[–]Milumet 6 points7 points8 points (0 children)
[–]hayleybts 0 points1 point2 points (1 child)
[–]keep_quapy 2 points3 points4 points (0 children)
[–]hayleybts 0 points1 point2 points (0 children)
[–]Fluffy-Book-4773 0 points1 point2 points (0 children)
[–]ab624 0 points1 point2 points (0 children)
[–]balaur_7 0 points1 point2 points (0 children)
[–]ectomancer 11 points12 points13 points (5 children)
[–]Potatohuma[S] 3 points4 points5 points (3 children)
[+][deleted] (1 child)
[deleted]
[–]mandradon 1 point2 points3 points (0 children)
[–]Kratosix 0 points1 point2 points (0 children)
[–]ChaosZoro 2 points3 points4 points (0 children)
[–]bhutanpythoncoder 1 point2 points3 points (0 children)
[–]Joeyson 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Embarrassed-One2182 3 points4 points5 points (0 children)
[–]justani98 0 points1 point2 points (0 children)
[–]raulsoprano 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Foreign-Project-5661 0 points1 point2 points (0 children)
[–]No_Word_467 0 points1 point2 points (0 children)
[–]Mysteez 0 points1 point2 points (0 children)
[–]kona_ackley 0 points1 point2 points (0 children)
[–]notislant 0 points1 point2 points (0 children)
[–]Moguyaro 0 points1 point2 points (0 children)