Can I 'str' 'Monty Python' to a string, then print it? Thanks


#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


#2

Would someone tell me why I can’t?


#3

After upvoting your own topic, should we? Or have you figured it out on your own enough to warrant the vote? You see, to some of us here, this is not a game.


#4

sorry, new one not sure what vote mean, sorry again


#5

:flushed:



#6

There’s nothing in python allowing you to write

monty python

This isn’t a thing, there’s no way to read this, it doesn’t mean anything.
So the question then is what you meant to do, which is represent text.
Next up you can look for information on how to represent text in python. A good place to find this would be to look up an example of something that prints a message, like a hello world program – it has to represent hello world
https://duckduckgo.com/?q=python+hello+world

More generally, you have to use the things that do exist, combine them to make things happen. (As opposed to writing something and hoping python understands it)

In order to convert something to a string, you already need to have a value, and monty python isn’t anything at all, so you can’t turn it into a string. And, because there is syntax for entering strings directly into code, there’s no need to convert them to string.

Alternatively, if you had no value at all, you could use something that does create a string for you, but if you have no value then you also have no way of communicating what letters there should be in the string.

empty_string = str()

#7

Thank You Very Much! Your answer is very logical, so I know what the problem is. :star_struck:


#8

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