Maximum of a list X40606


Statement
 

pdf   zip

html

The maximum of a list t is the largest element that it contains. For example, the maximum of [1, 2, 3] is 3, the maximum of [1, [2, 3], 4] is 4, and the maximum of [[[1]]] is 1. The maximum of [] is defined to be 0.

Write a program that prints the maximum of every given list.

Define and use a recursive function

maximum(t)

that returns the maximum of a list t.

Hint

Using the ast package, you can extract the list t encoded in a string s with t = ast.literal_eval(s).

Input

The input consists of several lists of non-negative numbers.

Output

Print the maximum of every given list.

Public test cases
  • Input

    []
    [1, 2, 3]
    [1, [2, 3], 4]
    [[[1]]]
    

    Output

    0
    3
    4
    1
    
  • Information
    Author
    Gabriel Valiente
    Language
    English
    Official solutions
    Python
    User solutions
    Python