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


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


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


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