Longest String Python How To / Tutorial

preview_player
Показать описание
Write a program that takes two strings and outputs the longest string. If they are the same length then output the second string.

Ex. If the input is:

almond pistachio
the output is:

pistachio

Code

public class LabProgram {
public static void main(String[] args) {


}
else{
}
}
}
# write a program that takes in 2 Strings as input and returns the longest string.
# If they are the same size return the second one.
# Example Car & Cars Print Cars
# Example Car & Key Print Key

string1 = input()
string2 = input()

if (len(string1) len(string2)):
print(string1)
elif (len(string2) len(string1)):
print(string2)
else:
print(string2)
python tutorial,python,python longest string in list,python programming,python coding tutorial,python longest common substring,python longest palindromic substring,python programming tutorial,python string,python string to int,python longest,python string format,python longest length,python string split,python practical tutorial,python string interpolation,python longest increasing subsequence,python longest prefix match,python longest common prefix
Рекомендации по теме
Комментарии
Автор

Simple, straightforward, and easy to understand. Thanks for the help, your code was the best I found after an hour of search.

chadsmalls
visit shbcf.ru