Get stuck with this python class and dont know why it keeps showing something is wrong with syntaxerror and "else"

Hi, Can anyone write down the code or have better way to solve this. I would be very appreciated.
this is the following task:

  • Create two classes:

1.Parameters

my_list

my_dict

Methods

list_is_list

return True if self.my_list is a list, otherwise False

sort_and_return_list

sort and return the list

return_first_three_elements

return first 3 elements from list

return_reversed_list

return the list reversed

dict_is_dict

return True if self.my_dict is a dict, otherwise False

return_all_values_from_dict

return all values from self.my_dict

add_key_and_value_to_dict

  1. Parameters

key

value

Add key and value to the dict

Return the new dict

MyPythonHandler

Inherits from ListAndDictHandler

  1. Parameters

my_variable

Methods

multiply_by_three

multiplies self.my_variable by 3 and returns the value*

here is my code:

my_list =[1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998]

list_is_list=[my_list]

class my_list(list_is_list):
def init(self, my_list):
self.my_list= my_list

def my_list(self): 
    return True
    else
    return False

reversed_list=list_is_list[::-1]
first_three_element =reversed_list[:3]
first_three_element[0]=1991
print(first_three_element)

my_dict=[‘name’:‘Ann’, ‘last_name’: ‘Johansson’, ‘age’: ‘29’]

class my_dict():

def __init__(self, my_dict, dict_values):

    self.my_dict= my_dict
    self.dict_values=dict_values

def  my_dict(self):
    return True
    else:
    return False

dict_value= my_instance.return_all_values_from_dict ()

print(f’the dict value are:{dict_values}')

dict_is_dict =my_instance.dict_is_dict()

print(f’The dict is a dict: {dict_is_dict}')

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.