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 in Python by anonymous
• 120 points
77 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 by Gitika
• 41,080 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 in Python by Roshni
• 4,530 points
705 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 in Python by anonymous
• 220 points

edited May 18 by Gitika 350 views
0 votes
1 answer

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

Hi. This error is caused because you ...READ MORE

answered May 12, 2019 in Python by Anjali
33,686 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
5,976 views
+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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,446 views
0 votes
0 answers
+4 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,800 points
1,076 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 in Python by Gitika
• 41,080 points
190 views