Test Failed unsupported operand type s for - tuple and list

0 votes
Hey! I'm trying to learn python and here is my first assignment. I got the error message unsupported operand. It compiles and runs in pycharm but when I uploaded it to Gradescope I got this error. Please help! 
import statistics


class Person:
    """
    Represents a person. Contains methods for
    getting name and age
    """

    def __init__(self, name, age):
        """ Returns a person object with the given name and age"""
        # Leading with an underscore indicates
        # that the name and age are intended to be private
        self._name = name
        self._age = age

    def get_name(self):
        """Returns the name of the Person"""
        return self._name

    def get_age(self):
        """Returns the age of the Person"""
        return self._age


def basic_stats(l):
    ages = []
    for i in range(0, len(l)):
        print(l[i].get_name() + " " + str(l[i].get_age()))
        ages.append(l[i].get_age())
    return [statistics.mean(ages), statistics.median(ages), statistics.mode(ages)]


"""
p1 = Person("Kyoungmin", 73)
p2 = Person("Mercedes", 24)
p3 = Person("Avanika", 48)
p4 = Person("Marta", 24)

person_list = [p1, p2, p3, p4]
# basic_stats(person_list)
print(basic_stats(person_list))  # should print a tuple of three values
"""
Oct 1, 2020 in Python by anonymous
• 120 points
2,910 views

1 answer to this question.

0 votes

Hi, @There,

Check what are you passing.. the operation what u are doing not supported for tuple/list

answered Oct 5, 2020 by Gitika
• 65,770 points

Related Questions In Python

0 votes
1 answer

TypeError: unsupported operand type(s) for -: 'list' and 'int'

Hey, @William For me the code is working ...READ MORE

answered Mar 11, 2020 in Python by Roshni
• 10,480 points
3,519 views
+1 vote
0 answers

TypeError: unsupported operand type(s) for /: 'list' and 'list'

This is my part of code, why ...READ MORE

May 17, 2020 in Python by anonymous
• 220 points

edited May 18, 2020 by Gitika 2,936 views
0 votes
0 answers

How can I solve it? TypeError: unsupported operand type(s) for /: 'float' and 'list'

I am trying to calculate numerical integration ...READ MORE

Nov 17, 2020 in Python by asimsek
• 120 points
13,832 views
0 votes
0 answers

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Hi guys i have below code . ...READ MORE

Oct 30, 2019 in Python by sumanth
• 190 points
12,022 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,464 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,125 views
0 votes
3 answers

TypeError: unsupported operand type(s) for -: 'str' and 'str'

& is "bitwise and" operand in Python, you ...READ MORE

answered Dec 11, 2020 in Python by Rajiv
• 8,870 points
80,681 views
0 votes
1 answer

String is immutable data type. String.replace() So why there is command for string to replace the values....??

Hey, @Nelson, replace() actually returns a *copy* of ...READ MORE

answered Mar 30, 2020 in Python by Gitika
• 65,770 points
5,764 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP