Q Would like assistance with these if statements in Python t

Q: Would like assistance with these if statements in Python to further know others, thanks for the details.

Complete the following functions: Worksheet : if statements

1. def earlier_name (name1, name2):

Return the, name or name 2, that comes first alphabetically.

>>> earlier_name (\' Jen \', \' Paul \')

\' Jen \'

>>> earlier_name (\' Colin \' , \' Colin\')

\' Colin\'

\"\"\"

Solution

def earlier_name (name1, name2):
if name1.lower() < name2.lower():
print name1
else:
print name2

When we call function earlier_name we are paasing two arguments and in the function it is compairing both the arguments and will print the smaller one.

In this i used the lower() function which is handling case sensitive issue, as it will convert uppercase into lower.

Note: Indentation is important

Q: Would like assistance with these if statements in Python to further know others, thanks for the details. Complete the following functions: Worksheet : if sta

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site