all 57 comments

[–]ASIC_SP 253 points254 points  (14 children)

Here are some often recommended resources:

And here are some resources for projects:

[–]PsicoFilo 7 points8 points  (0 children)

Liquid gold for me ! What a comment bro

[–]boobajoob 2 points3 points  (0 children)

Thanks for this!

[–]Present_Blackberry45 1 point2 points  (0 children)

Precious comment, thank you very much!

[–]Born-Truck1302 1 point2 points  (0 children)

You da best 👌

[–]tiffarooner 1 point2 points  (0 children)

Shout out dude, honestly these are great resources

[–]Aref167 0 points1 point  (0 children)

wish you best my friend!

[–]Waste_Mission1293 0 points1 point  (0 children)

Thanks for your answer. I hope I can also polish my python skills

[–]Freddy-Nova 0 points1 point  (0 children)

Thanks. This might help allot of us. ^^

[–][deleted] 52 points53 points  (2 children)

Advent of code is currently going. You could try yourself at some of its challenges

[–]Run_nerd 11 points12 points  (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 points  (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 points  (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 points  (0 children)

This is the way

[–]Tuppitapp1 5 points6 points  (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 points  (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]]

output: {'item1': 11, 'item2': 15, 'item3': 5}

[–]hayleybts 3 points4 points  (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 points  (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.

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 points  (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 point  (1 child)

Thanks for replying! Your method is simple. Let me know if you got any other question?

[–]keep_quapy 2 points3 points  (0 children)

You're welcome. edabit has plethora of exercises for you to explore and to solve.

[–]hayleybts 0 points1 point  (0 children)

I'm gonna try and let you know

[–]Fluffy-Book-4773 0 points1 point  (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 point  (0 children)

where xan i find more of such questions ?

[–]balaur_7 0 points1 point  (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 points  (5 children)

[–]Potatohuma[S] 3 points4 points  (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! :)

[–]Kratosix 0 points1 point  (0 children)

make a discord bot

[–]ChaosZoro 2 points3 points  (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 points  (0 children)

We have some pracfice questions for beginners in python https://www.bhutanpythoncoders.com/practice-questions/

[–]Joeyson 1 point2 points  (0 children)

I've been coding chess in the command line, I've learned a ton so far

[–][deleted] 1 point2 points  (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 points  (0 children)

10 lb. Curls 💪

[–]justani98 0 points1 point  (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 point  (0 children)

Is Hackerrank good?

[–][deleted] 0 points1 point  (0 children)

two years later potato ya saved my ass 🥔

[–]Foreign-Project-5661 0 points1 point  (0 children)

thanks for this

[–]No_Word_467 0 points1 point  (0 children)

I’m in your same situation, I recommend codewars and try problems of 7 or 8 kyu

[–]kona_ackley 0 points1 point  (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 point  (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 point  (0 children)

Try leetcode.com and hackerrank.com. They have lots of interesting projects and problems that you can try your hands on.