u/Effective_Celery_515

Getting a TypeError when trying to pass two arguments to my function but I defined it with two parameters

I am working on a small assignment where I need to calculate the average of a list of numbers using a function. My function takes two arguments but every time I call it I get a TypeError and I cannot figure out what I am doing wrong because the number of arguments looks correct to me.

Here is my code:

python

def calculate_average(total, count):
    return total / count

scores = [85, 90, 78, 92, 88]

result = calculate_average(sum(scores), len(scores), scores)
print(result)

And here is the exact error I am getting:

TypeError: calculate_average() takes 2 positional arguments but 3 were given

I read the error message and I thought my function only takes two arguments so I am confused about where the third one is coming from. I have looked at this for a while and I cannot spot it. Can someone help me understand what I am missing here?

reddit.com
u/Effective_Celery_515 — 3 days ago

I called back the scam tax number by mistake, what do I do now?

I posted here a couple days ago about a suspicious voicemail from a so called tax mediation office and everyone confirmed it was a scam. The problem is I had already called back before I got those replies and I stayed on the line for maybe two or three minutes before I got suspicious and hung up.

I did not give them any personal information like my SSN or bank details but I am not sure if just calling back puts me at risk somehow. My phone number is obviously already compromised but is there anything else I should be worried about? Should I be monitoring my credit or doing anything specific right now or am I overthinking this?

reddit.com
u/Effective_Celery_515 — 4 days ago

I keep writing Python code that "works" but I have no idea why it works is this normal for beginners?

I started learning Python about six weeks ago and I have been following along with tutorials and trying small practice problems on my own. The strange thing is that sometimes I manage to get my code to actually run and produce the right output, but when I sit back and think about it, I genuinely do not understand why it worked. I kind of just tried different things until something clicked.

For example, I was working with loops and list comprehensions recently and my solution gave the correct answer, but if someone asked me to explain every line in detail, I think I would struggle. I am not sure if I am moving too fast, or if this is just a normal part of the early learning curve where things slowly start making sense over time.

Has anyone else gone through this phase? How did you eventually get to the point where you understood your own code confidently? Should I slow down and focus more on understanding before moving forward, or does the understanding naturally come with more practice?

reddit.com
u/Effective_Celery_515 — 6 days ago

Hey everyone,

I’m currently taking an intro programming class online, and we’re in week 2 right now. Last week was pretty straightforward — mostly basic math, data types, and using print and input, which I was able to get through without too much trouble.

This week though… it’s definitely a step up

I understand the basics of for loops, while loops, and if/elif/else, but I’m struggling with how to actually start this assignment and put everything together in a clean way.

I’m not looking for anyone to write the code for me — I just want help breaking the problem down so I can approach it step by step and learn it properly.

Here’s what the assignment is asking:

  • Prompt the user for the day of the week, plus high and low temperatures (using a loop)
  • Keep track of total highs and lows
  • Calculate weekly averages
  • Use conditionals to display a message based on the high average (very hot, hot, warm, etc.)
  • Output the last entered day and temps, along with the averages and final message

I think where I’m getting stuck is structuring the loop and figuring out the best way to store and update the data as the program runs.

If anyone has advice on how you’d break this down or where you’d start, I’d really appreciate it. Thanks in advance!

reddit.com
u/Effective_Celery_515 — 14 days ago

so i have been asked this a few times now by people just starting out and i figured i would just make a post about it because i wasted a lot of time early on not knowing where to look.

first thing that actually worked for me was just starting with the official python docs. sounds boring but the beginner section is genuinely well written and explains things clearly without overwhelming you. most people skip this and i think that is a mistake.

for actual structured learning i used cs50p which is harvards free python course on edx. it is completely free to audit and the problems they give you are actually challenging in a good way. this one genuinely pushed me more than any paid course i tried before.

automate the boring stuff with python is another one that helped a lot. the whole book is free to read online on the official website and the projects in it are actually useful real world stuff not just made up exercises.

for practice i used codewars and exercism. codewars has problems ranked by difficulty so you can start easy and slowly move up. exercism is good because you get actual feedback on your code which is rare for a free platform.

and honestly the biggest free resource is just this community and stackoverflow. whenever i got stuck i would post here or search my error on stackoverflow and almost always found someone who had the same problem.

you do not need to spend money to learn python seriously. the free stuff is genuinely good if you know where to look and stay consistent with it

reddit.com
u/Effective_Celery_515 — 20 days ago