String Slicing Concepts

 s = "You are learning Python"

print(s[:]) # outputs "You are learning Python"
print(s[1:6]) # outputs "ou ar", because s[1] is "o", s[5] is "r"
print(s[10:]) # outputs "arning Python" because it's the slice from index 10 to the end of the string
print(s[:10]) # outputs "You are le" because it's the slice from the start to index 9

Comments

Popular posts from this blog

XAMPP, SQL BASIC COMMANDS

The Minion Game Hackerrank Solution

Arrays - DS | HackerRank Solutions