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

adam = "john"
adam = adam + "mike"
4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by paddy3118
0

It depends on the type of data and how you intend to use it.

>>> adam = "john"
>>> adam += "mike"
>>> adam
'johnmike'
>>> ' '.join([adam, 'fred'])
'johnmike fred'
>>>
0

If you want to do that to an int and you just want to add it on the end then you could go:

>>> 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
0

You seem to be wanting to store a collection of information. Have a look at lists, sets and dictionaries in the python documentation.

- Paddy.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.