Classes and object

I have question to print the longest(in seconds) music in the class (how is it long and what is their name)

so i have this code and im not sure is it correct

> def longestmusic(listofmusic,typeofmusic)
>       longest=0
>       longestmusic=[]
>       for s in lisofmusic:
>             if (s.typeofmusic==typeofmusic)
>                       if (s.longest > longest)
>                                longest=s.longest
>                                longestmusic=s.typeofmusic
>                                return(s.typeofmusic()[:1])
>                       else:
>                                return(s.typeofmusic()[:1])
>           print(+longest,+longestmusic)

Hello there,

You have a few syntax errors of missing :.

Also, when you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

Please use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks are not single quotes.


@minko Can you show us a sample of what listofmusic looks like?

i have construct and its like :
and i dont need to write a whole code i only need to type a that definition its like school exam

class music:
  def __init__(self,nameofmusic,year,howlong,typeofmusic,nameofauthor):

You have this defined in your class yet you wrote:


There is no longest property. Also, if you want the name of the music, why are you referencing typeofmusic in the following line?


im using typeofmusic because i want to print how long is it and what type of that music
also if i something type wrong the problem is not written in english so i need to translate it .