Felipe Miotto
Felipe Miotto

Reputation: 33

Printing and Returning issues in Python

i'm having a newbie problem with python, my function does not return nothing on console.

Here's the code;

planets = [
    ("Mercury", 2440, 5.43, 0.395),
    ("Venus", 6052, 5.24, 0.723),
    ("Earth", 6378, 5.52, 1.000),
    ("Mars", 3396, 3.93, 1.530),
    ("Jupiter", 71492, 1.33, 5.210),
    ("Saturn", 60268, 0.69, 9.551),
    ("Uranus", 25559, 1.27, 19.213),
    ("Neptune", 24764, 1.64, 30.070)
]
name = lambda planet: planet[0]
size = lambda planet: planet[1]
density = lambda planet: planet[2]
distance = lambda planet: planet[3]

planets.sort(key=size, reverse=True)
print(planets)

def lettercase(planets):
    return all(n[0].isupper() for n in planets

lettercase(planets)

I only have the list organized and printed the way i asked, but not the uppercase "checker" function.

I'm trying to organize a list for a specific element and later create a function that checks if the first letter of each element is in Uppercase, if so returns True, if not returns False.

Thanks in advance and sorry for the newbish question, i'm a beginner in programming.

Upvotes: 0

Views: 54

Answers (1)

Barmar
Barmar

Reputation: 782737

The return value of functions isn't printed automatically. You need to call print() to do it.

print(lettercase(planets))

Also, you need to call the name function in lettercase:

def lettercase(planets):
    return all(name(n)[0].isupper() for n in planets)

Upvotes: 2

Related Questions