+ 2
Solved-Python Beginner - Strings List Problem "Write a program that takes an input string and outputs the 3rd character of the s
Hi! So the problem is "Write a program that takes an input string and outputs the 3rd character of the string". This is from 'Time to Practise' for Python Beginner. My attempt: str = input() print(str[3]) When I ran the above code, the result showed that Test Case 1 is correct but Test Case 2,3,4 are wrong. Not sure what I'm missing, appreciate someone helping :) --- solution Mistake was that it said "3rd element" which means its supposed to be 2, not 3! :)
12 ответов
+ 3
actually the index starts from 0, 1, 2, 3, .............so on
the third character will be index of 2. try it
+ 6
Try it
str = input()
print (str[2])
+ 3
Try this
str = input()
print (str[2])
+ 2
I just now came back to delete this question because realised my mistake was that it should have been 2 instead of 3! Thanks for the help :)
+ 2
Try this
str = input()
print (str[2])
+ 2
str=input()
print(str[2])
+ 1
str = input()
print (str[2])
+ 1
str=input()
print(str[2])
+ 1
t = input()
print(t[2])
also right answer
+ 1
This code is for all cases
str=input()
if len(str)>=3:
print(str[2])
else:
print("Error")
0
Str = input()
Print (str[2])
- 1
here is the correct answer:
str = input()
print (str[2])