[Tutor] stored variable :p:

Paradox paradox at pobox.com
Wed Sep 19 06:12:11 CEST 2012


On 09/19/2012 09:21 AM, Lamar iVisionary wrote:
>
> Trying to write the following in Python.
>
> "Hi, my name is Bob!",
>
> .What is your name?
>
>
>  print " Hi," + "my name is Bob!,
>
>  strname= raw_input ("What is your name?")
>
>
>
>
> Hi #######, nice to meet you!
> I'm 18. How old are you?
>
>
>
>
>
> I cant figure out to get the stored variable / (Name) to appear when I 
> respond Hi ####, nice to meet you.
>
> Any help with this would be great.
>
>
>
>
>
Just a beginner here myself but I think you could just use a string 
substitution to accomplish what you want.

For example:

sayWord = "Ni!"
print "The knights who say %s" % sayWord

Will produce:

The knights who say Ni!

You can do it directly too but usually replacing with a variable gives 
more flexibility.

thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120919/6b10e18d/attachment.html>


More information about the Tutor mailing list