Lucky Seven - Simple String

Title: Lucky Seven - Simple String Indexing

:small_blue_diamond: Problem Understanding:
We are given a string S of length 10.
Chef considers the 7th letter as lucky.
We need to print the 7th character in the string.

:small_blue_diamond: Important Concept:
In Python, indexing starts from 0.
So:
1st character β†’ index 0
2nd character β†’ index 1
…
7th character β†’ index 6

:small_blue_diamond: Approach:

  • Take input string S
  • Print the character at index 6

:small_blue_diamond: Code:
s = input()
print(s[6])

:small_blue_diamond: Example:
Input: proceeding
Output: e

Explanation:
String = p r o c e e d i n g
Index = 0 1 2 3 4 5 6 7 8 9

7th character = index 6 = β€˜e’

:small_blue_diamond: Time Complexity:
O(1)

:small_blue_diamond: Space Complexity:
O(1)

@kit28aiml007

The 7th character of β€œproceeding” is β€œd” - as your explanation section shows, and as stated on the problem statement page.