Longest String Python How To / Tutorial

Pubblicato il: 15 gennaio 2024
sul canale di: 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


In questa pagina del sito puoi guardare il video online Longest String Python How To / Tutorial della durata di ore minuti seconda in buona qualità , che l'utente ha caricato RubenOrtega 15 gennaio 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 208 volte e gli è piaciuto 1 spettatori. Buona visione!