| | |
Adding info to a variable
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 58
Reputation:
Solved Threads: 0
I have the variable Adam that contains some information.
Later on i have some more information to add to the variable adam. How can this be done
something like
Later on i have some more information to add to the variable adam. How can this be done
something like
Python Syntax (Toggle Plain Text)
adam = "john" adam = adam + "mike"
•
•
Join Date: Mar 2007
Posts: 110
Reputation:
Solved Threads: 31
It depends on the type of data and how you intend to use it.
Python Syntax (Toggle Plain Text)
>>> adam = "john" >>> adam += "mike" >>> adam 'johnmike' >>> ' '.join([adam, 'fred']) 'johnmike fred' >>>
If you want to do that to an int and you just want to add it on the end then you could go:
python Syntax (Toggle Plain Text)
>>> adam = 123 >>> john = 456 >>> #if you just add them together they don't add on to the end, >>> print adam+john 579 >>> print str(adam)+str(john) 123456 >>> # and then you can turn that back into an int using the int() function
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
![]() |
Similar Threads
- fstream Tutorial (C++)
- Javascript MP3 Player (JavaScript / DHTML / AJAX)
- Creating a multi-dimensional Session variable (PHP)
- C programming - need some help (C)
- Adding pictures (Visual Basic 4 / 5 / 6)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- html table to .csv (HTML and CSS)
- reading a file into code (Java)
- How do I create a program using an Array ? (C++)
Other Threads in the Python Forum
- Previous Thread: Lame_enc.DLL any way to use it with python???
- Next Thread: Reading XML data
| Thread Tools | Search this Thread |
abrupt accessdenied anti apache application approximation argv array beginner book builtin calculator change converter countpasswordentry curved dan08 dictionaries dictionary dynamic edit enter examples file float format function gui heads homework import inches input java keyboard lapse launcher library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl python random recursion redirect remote reverse scrolledtext session simple software sprite statictext string strings syntax table terminal text textarea thread threading time tlapse trick tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython





