Allewyn


#1

Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output


Concerning dot notation:
ministry = “The Ministry of Silly Walks”

len(ministry)
print ministry.upper()

I’m supposed to be getting 27 but keep getting the above in all caps. How does upper() relate to len()?


#2

Hi @allewyn,

You have this expression …

len(ministry)

… but you did not print its value.

They are two different things.

  • upper is a method that converts a string to uppercase.
  • len is a built-in function that can be used to reveal the number of characters in a string.

#3

I hope I’m not wasting your time. I included instructions so you could see what I’m trying to do:

On line 7, call the len() function with the argument ministry.
On line 8, invoke the ministry’s upper() function:

  1. len(ministry)
  2. print ministry.upper()

the error is
It looks like you printed “THE MINISTRY OF SILLY WALKS” instead of “27”.
Where do I print len()? Is there a mistake in the instructions or something?


#4

Lines 3 and 4 already have the print statement included when the lesson starts
It seems like you deleted that print statement.

You need to print len(ministry)


#5

Helping users is a very worthwhile use of time, so there’s no problem.

You need to display the value of the expression, len(ministry). To do that, place the expression in a print statement. See @fight_dragons’s reply regarding how to do that.


#6

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