string = 'starry sky'
print(string.find('a'))
line = 'Kate on her skateboard!'
print(line.find('Kate'))
line = 'Kate on her skateboard!'
print(line.find('Katie'))
line = 'Kate on her skateboard!'
print(line.find('ate'))
#there are 2 ""ate"" substrings in variable line, but python shows the starting index of the first occurence.
replace() function
replace()
function
replaces
a
specified
character
or
substring
with
another
in
a
string.
We
can
also
specify
the
number
of
times
the
character
or
substring
needs
to
be
replaced.
If
count
is
not
specified
python
replaces
all
the
occurrences
string.replace('oldWord','newWord',count)
#oldWord is a word you want to replace#newWord is a word you want to replace with#count is the number of times you want to replace oldWord with newWord
line = "O’really? bababa!"
print(line.replace('ba', 'ha'))
line = "O’really? bababa!"
print(line.replace('ba', 'ha', 2))
#We can also replace two words in one go
line = 'I saw Dave on his bicycle.'
print(line.replace('Dave', 'Donna').replace('his', 'her'))
Sign In
You will receive an OTP for verification purposes.
Our Result
Sanatan is our in-house coding prodigy who ranked as a Top 2 finalist in Google’s Code-In competition (now defunct). He’s a great example of how starting early in your coding journey can be so empowering that you can even find yourself tackling challenges at tech giants like Google!
What the world says about Tekie
“While most competing platforms are teaching students block-based programming, Tekie is attempting to teach young students the fundamentals of text-based programming, which is to write actual coding language syntax.”
The founder elaborates, “We came up with the idea of animation because that helps bring imagination to reality. We also wanted to make learning interesting and engaging.”
Parents trust us.
The best learning happens when you are not learning, you are playing and enjoying. For Medha, learning has been a pleasant glide, thanks to a warm and interpersonal method of teaching; it's like she is learning from a friend who knows her! She loves the puzzles and other methods used- both experimental and classic.