+ 3
How does it give shortest string?
def short_string(x,y): if Len(x)<=Len(y): return x else: return y print(short_string("Manish","Ravi"))
7 odpowiedzi
+ 5
def shortest_string(x, y):
if len(x) <=
len
(y):
return
x
else:
return
y
+ 4
In point with strings "len" function returns number of chars in string. If one string contains more characters than second, you will get first.
0
def shortest_string(x, y):
if len(x) <=
len
(y):
return
x
else:
return
y
0
len
return
return
0
len
(y):
return
x
else:
return
y
0
def shortest_string(x, y):
if len(x) <= len(y):
return x
else:
return y
0
def shortest_string(x, y):
if len(x) <= len(y):
return x
else:
return y