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"

Recommended Answers

All 3 Replies

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

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

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

- Paddy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.