A string cannot be divided by an integer, only sliced.
I would like to speak about the variable names. Statistics has some fairly well defined concepts, and using variable names that reflect that is far more useful than just inventing them.
A sample space is a collection of data surveyed from a sample population. The median is the middle value of a sorted sample space. When two values fall in the middle, they are averaged. So I wouldn't begin by suggesting that the median is a list. It's a value.
Given that we are handed a list, we should not have value in the variable name. It is not semantic. When we describe the inputs we self-document the code.
Took me a while to edit the above, but the answer may be in there.
Let's examine the code in the OP...
med = 
value = str(med_value)
total = 0
for i in value:
y = str(len(value))
total = total + y / x
We know that the first line is removed.
Given that the parameter is a list, the second line will raise an exception. We need to use string formatting to represent a list as a string. The loop that follows assumes an iterable. A list is one already.
for i in med_value:
Here we stall. Problems solved means long explanations. Sometimes just looking at it solves it. Let's give that a try, first, eh?
As I am new, my answer might not be very satisfying but I will try my best to explain how I understand the for loop. - I only used codecademy to practically learn Python, so starting from early lesson you will build confidence about loops and how and when to use each. But I think so far for loop is the most used because it is easier to understand and it gets your code work. - for loop is very suitable if you are working with lists, dictionaries, strings or any type of series data as it allows you to iterate through the length of that data, through each item and also allows you to run the code contentiously until it reach the last item in "say" a list. for example you can make it sounds like this: for each item in my_list please divide each item by 2 and print the results or return the result, for loop will carry this mission until it reaches that last item in you list . with a lot of practice, you will have the feeling that for loop is the most understandable loop in python programming. I hope this was helpful.
Wow.!! thank you for pointing that out for me, as I am new to coding, I don't really see the shortest and efficient way for coding. Your code is super simple and easy. Thank you for sharing that. Best of luck with coding.