I need help about Dot Notation


I tried everything but nothing..


please post your formatted code


ministry = "The Ministry of Silly Walks"

print ministry.upper() = "The Ministry of Silly Walks"

On line 3, call the len() function with the argument ministry.
On line 4, invoke the ministry's .upper() function.


Ok there is just a little bit of confusion going on here.

Print is a stand alone function. It prints what ever follows it. dot notation is only used for string modulation.
The len function takes in a value and returns the number of spaces/chars in it(it does not modify the string so dot notation is not appropriate). So your first problem would be resolved with

print len(ministry)

The second issue is about the upper function. This function returns the string but in all caps aka it does string modulation and uses dot notation. Once again we call print on its own. We are looking to modify the string contained in the variable "ministry" with the upper() function so we do

print ministry.upper()

You do not need to add the contents of ministry in quotes like that. We already have it stored in a varaible, and retyping it kind of defeats the purpose of variables in the first place.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.