r/learnpython • • 9d ago

Struggling to solve beginner tasks after learning Python basics

Hello! I've learned the basics of Python (variables, loops, conditionals, etc.), but I’m struggling to complete actual beginner tasks—things like counting vowels, "Fake Binary," calculating the sum of numbers, determining BMI, etc.

When I look at a task, my mind goes blank and I don't know how to start or turn the problem into code. Why am I unable to do these? What is the real issue here, and what exact study method or solution can help me overcome this?

I’m starting to lose my motivation and feel like giving up if I can't figure out how to bridge this gap. Any practical advice would really help!

4 Upvotes

19 comments sorted by

6

u/jbenze 9d ago

There were a lot of good answers in the thread you made about this a few hours ago. You should start going through those answers. Start out by writing down how you would solve the problem step by step before you start coding.

1

u/johlae 9d ago

Let me guess, you learned by watching youtube videos? That doesn't work. You need to do exercises, lots of them actually.

Did you do https://cs50.harvard.edu/python/ or https://programming-26.mooc.fi/? These courses do have exercises. Go full Trump mode: drill, drill, drill.

1

u/ThinCreme1098 9d ago

That’s good, but I don’t know English well enough to be able to watch the video.

1

u/SprinklesFresh5693 3d ago

You need more practise, thats it.

Face errors, get used to them, and learn from mistakes. Theres not much else other than practise and googling what you dont understand. Maybe looking for a free book online , but thats it.

1

u/ThinCreme1098 3d ago

Everyone tells me that, but how am I supposed to get practical experience?

1

u/SprinklesFresh5693 2d ago

First, why are you learning python, what do you plan to do with the language? Thats the first question, based on that we can help you

1

u/ThinCreme1098 2d ago

For many purposes—such as data science, data analytics, working with schemas and scripts, and creating bots, among other things.

1

u/SprinklesFresh5693 2d ago edited 2d ago

Great, so numeric analysis and bots. Now you have your end goal.

Now to get better , why not do some analysis of a field youre interested in, and try learning how to create a bot?

Just open the notebook, or whichever ide you use, get a dataset and start thinking, what outcomes do i want to see from this data, how doesit look like, what are the tendencies, etc.

On the other side, think of a bot you want to create, and google how to create a bot, and do some research and code yourself both projects. Dont copy paste what AI gives , look at forums, look at documentation, and think.

Now you will get errors, you will get stuck, but dont worry! Everyone feels the same way when they are starting out, but as you do more and more projects, things will stick, and youll start understanding more about the language and about what conclusions youre looking for, and how to obtain them progrmaming, you dont need to learn everything about a language, specially one so broad as python, just start by learning only what you need for a job on the field youre interested in, data science and bots, and only expand when you have a good understanding of those conceps, and only if you want to, again, you dont need to know everything about a language. Furthermore, keep reading articles, books, watching some videos (you dont really need to follow the video coding, just get the ideas and concepts to later expand on them yourself, because you would already know the basics, after knowing the basics you dont really need to follow the tutorial coding everything yourself, just think about the concepts and try to apply them on your field), to keep getting in concepts and ideas about python. Id really suggest you follow people that use python and that post regularly on linkedin, ive learnt a lot from those, although in R, not python, but the same idea applies here.

Then start applying for jobs, and the moment you find one that uses python, you will find yourself using it all day everyday, getting stuck, researching and progressing, but again, dont copy paste what AI gives you because that way you wont learn much though.

3

u/Umustbecrazy 9d ago

Programming is essentially a logic puzzle. Like a puzzle you start piece by piece.

If you can clearly say what needs to be done in each step, then you don't know the language well enough yet to implement it.

If not, then you need to try and work on your logic process.

Beginner tutorials just show the easiest example.

So your lacking practice/ability in one of the two.

-1

u/KingTreacherice 8d ago

No its not a puzzle...its wash rinse repeat pattern recognition.....

2

u/Available_Safe1818 8d ago

What's the problem with counting the vowels? Have you tried anything?

1

u/Southern-Winner9245 9d ago

for counting vowels, try tracing 'cat' on paper first: write down the current letter and the count after each step. then turn those steps into a loop and check that you get 1.

1

u/Discordbothost 9d ago

the blank mind thing usually happens because tutorials teach the pieces (loops, ifs) but not the shape of a solution. most of the tasks you listed are literally the same shape: start with an empty result, go through the input one item at a time, decide something about each item, add to the result, return it at the end.

fake binary as an example. in words: for each digit, if it's under 5 write 0, otherwise write 1. in code that's almost word for word:

def fake_bin(digits):
    result = ""
    for ch in digits:
        if int(ch) < 5:
            result += "0"
        else:
            result += "1"
    return result

count vowels is the same thing with result = 0 and result += 1. sum of numbers, same with result += n. so when you go blank, ask three questions: what does my result start as, what am i looping over, what do i do with each item. answer those in plain words first and the code mostly writes itself

1

u/Educational_Virus672 8d ago

problem solving is the key part of programming lacking it doesnt make you a bad programmer but it limits you. but let me clear one thing programmers dont memorize everything they just think differently so lets think the dev-way with an example. lets use your example count vowels(ik methds but this is better example)
first a dev breaks it down into
looking at letter oen by one -> checkign every vowels -> adding value if vowel -> returnign the value back

# here we define vowels
vowels =  ["a","e","i","o","u"]
question = "your text"

# lets look at letters one by one and add it to count
count = 0

for letter in question :
    if letter in vowels :  # now we check wether it is "in vowels"
        count += 1          # or count = count + 1
print(count)  # return the value

here we get value "3" back now instead of asking "how to do it" think abt "how to do these"

Note - you can add .lower() after question because python sees upper and lower case letter as different letters

1

u/datadriven_io 8d ago

Simply because one first needs to learn programming. Datadriven is great for python practice, especially before interviews. This means that one needs to know the basics behind programming, like problem solving, variables, loops, conditionals, functions, data structures, algorithms, etc.

1

u/captorwootfondly 7d ago

When your mind goes blank, try starting from the outside in - it's what I tell my students for exam programming questions:

  • write the function header + the return statement first

  • define the variables you know you'll need (e.g. count = 0)

  • then fill in the loop in the middle

So for counting vowels, you'd write this before thinking about the hard part:

def count_vowels(text):
    count = 0
    ...
    return count

Now the only question left is "what goes in the loop?" - which is way less scary than a blank file.

1

u/Classic-Mongoose-460 4d ago

You could try https://www.blockofbytes.com/, it might help you because it ramps up slowly from easy exercises to harder ones.

But to be honest I also kinda think that it's not the case that you are unable to count vowels or sum the numbers. I think it might be that you simply panic. It's perfectly normal that your mind goes blank at the beginning.

When you are faced with the problem in programming, the absolute first step is to become "friends" with the problem. Think about, analyze it, sure write some code but be at peace with the fact that at first it won't work or will throw an error. It's part of the process.

So I would say, face the problem, and simply give yourself some time, let your mind go "blank" and don't panic or feel bad about this. Read the problem description a couple of times, re word it in your head, explore it, have some "fun" with it, and then try to solve it by writing some code while giving yourself permission to fail. Just try again and again after first failure and you will get it after couple of tries.

0

u/nullptr_0x 9d ago

Not sure what resources you're using, but I have a free course I made for some friends that tries to be as interactive as possible in the actual lessons.

Maybe see if just a different perspective of teaching helps you overcome where you feel blocked.

https://understandit.dev

But just know that learning to program is very confusing for everybody.

-1

u/KingTreacherice 8d ago

Go get a weather api....learn how to read that struCture.....in that structure you will have lists, diCtionaries, all data types....then you san take that data put it in pandas and now you have a dataframe.....then you can build a dashboard with insights....