Longest String Python How To / Tutorial

Publicado em: 15 Janeiro 2024
no canal de: RubenOrtega
208
1

3.22 LAB: Longest string Write a program that takes in two strings and returns the longest string. If they are the same length then return the second string. Ex. If the input is almond pistachio the output is: pistachio 2259421066560.gay LAB 3.22.1: LAB: Longest string 0 / 10 ACTIVITY main.py Load default template... 1 Type your code here." 2 Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Run program Input (from above) main.py (Your program) Output (shown below) Program output displayed here Longest string
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

import java.util.Scanner;

public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);

String first =scnr.next();
String second =scnr.next();

if(first.length()greater than signsecond.length()){
System.out.println(first);
}
else{
System.out.println(second);
}
}
}
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


Nesta página do site você pode assistir ao vídeo on-line Longest String Python How To / Tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário RubenOrtega 15 Janeiro 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 208 vezes e gostou 1 espectadores. Boa visualização!