Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
For text = "Python Programming", find its length, its capital letters version, its small letters version and how many times the letter m appears.
len() counts all the characters, including spaces. Methods give a new string.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
len(text) is 18. Python has 6 characters, the space is 1, and Programming has 11.text.upper() is PYTHON PROGRAMMING.text.lower() is python programming.text.count("m") is 2. The word has two letters m, side by side.Answer: 18, PYTHON PROGRAMMING, python programming and 2.
Log in to join the discussion.
Loading…