| | |
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 advanced ansi anti apache application approximation argv array backend beginner binary builtin calculator change command converter countpasswordentry csv curved dan08 def dictionary edit event file float format function google heads homework inches input jaunty java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric obexftp output parameters parsing path phonebook pointer prime programming py2exe pygame pyopengl python random recursion redirect remote return reverse scrolledtext session software sprite statictext statistics string strings syntax terminal text thread threading time tlapse tuple twoup ubuntu unicode unit urllib urllib2 variable voip wordgame write wxpython





