Longest String Python How To / Tutorial

Veröffentlicht am: 15 Januar 2024
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video Longest String Python How To / Tutorial mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer RubenOrtega 15 Januar 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 208 Mal angesehen und es wurde von 1 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!