What will be the output of the following Python code?
str1 = 'PYTHON' print(str1[1:4])
2 Likes
YTH
The string 'PYTHON' is stored in the variable str1. Python uses 0-based indexing.
'PYTHON'
str1
Index Table:
The slice str1[1:4] selects characters from index 1 to 3 (excluding 4): YTH
str1[1:4]
Hence, the output is YTH.
Answered By
1 Like
Why is modelling important in AI project framework?
a = 5 b = 3 print(a > b and b < 3)
s = "Great Day" print(s.count('a')) print(s.startswith('g'))
What are Assistant Robots?