+ 2

I can't seem to find complete the code

Have been trying to learn python on solo learn but am struck on a practice question about lists. The question goes like this: write a program that takes an input string and outputs the 3rd character of the string. Then the code starts like this: text= input() #code starts here Your help will be greatly appreciated.

27th Feb 2024, 11:12 PM
melvin mwango
melvin mwango - avatar
3 Respuestas
+ 7
Your Problem is Simple: Then its code would be: text = input() # Logic text is str (string) print(text[2]) # 3rd Char of the string (text) Remember that Python arrays/lists always start with 0 so 2 would be the third value. And Basically a String is a List of Characters Always starting at 0 and going wherever you want Ex: text = "I am trying hard" print(text[0]) # = I print(text[1]) # = (blank space) print(text[2]) # = a print(text[3]) # = m print(text[4]) # = (blank space) print(text[5]) # = t ...
27th Feb 2024, 11:19 PM
José
José - avatar
+ 4
you can access string characters using index (index start from 0) print(text[2]) #will output the 3rd char
27th Feb 2024, 11:19 PM
Mohamed Beder Oumar
Mohamed Beder Oumar - avatar
+ 1
Sequence 0,1,2,3,4,5,6,7,8,9.,
29th Feb 2024, 10:47 PM
Asim Farheen ⭐⭐🤺👿👿
Asim  Farheen ⭐⭐🤺👿👿 - avatar