Python Basics String Count Sub-Strings

preview_player
Показать описание
Learn how to count sub-strings in python using a for loop, range and len function.

twitter: @python_basics

#pythonprogramming #pythonbasics #pythonforever
Рекомендации по теме
Комментарии
Автор

Very helpful, thank you! Amazed at how many videos you have uploaded. Looking forward to learning more

janfrog
Автор

Exactly what I was looking for. Thank you.

jetfuelmeme
Автор

Easy and simple to understand, really helped me out - thanks, man!

musicmanafm
Автор

The video is very simple and it clears the basics very easily. Thanks man for uploading such nice video. keep this going

souravmallick
Автор

here I was thinking about using the .count-method, however that shows a result of 3 as it cannot handle "dadad". cool vid as always! ^^

Eckister
Автор

You are a master! Thank you very much bro

sergioisaacpuentesto
Автор

If we don't know which string is to be found so can we write
for i in range (len(line)):
if (i:i +len(sub)==sub #sub string's occurrence to be found
count+=1

sasikannan
Автор

but this isn't going to work for overlapping there any other way

HoneySingh-ncip
Автор

How would you solve this problem using nested loops?
mystery_string = "cacacat cacacat"

#You may modify the lines of code above, but don't move them! When you Submit your code, we'll change these lines to assign different
#values to the variables.

#Add some code below that will count and print how many times the character sequence "cat" appears in mystery_string. For example,
#for the string above, it would print 2.
#
#This one is tricky! Think carefully about for-each loops, conditionals, and booleans. How can you track what character you're currently
#looking for? We expect you'll use a loop and a single big conditional, but there are other approaches as well. Try to stick with the topics
#we've covered so far.

uzmabailey
Автор

Is there a way to print on the same line the::: 'The number of times Dad is: answer

stevecarney