Use of str (object) why it doesnt also work this way?


#1

Thats the original one:
ministry = “The Ministry of Silly Walks”

print len(ministry)
print ministry.upper()

I was just wondering if would work this way:
ministry = The Ministry of Silly Walks

print str(len(ministry))
print str(ministry .upper())

it says there is a syntax error on line 1. But in the module before that i made:
pi = 3.14
print str(pi)

and it worked
What have i done wrong in the first code?

Strings and Console Output


#2

This will surely raise an exception. Without quotes, The looks like an identifier. Strings always need quotes.


#3

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