I just recently started using Python and I was wondering if there was a way to increase a value in a list.

Recommended Answers

All 2 Replies

Yes, mylist[2] += increment for example increments the third item in mylist. Lists are mutable objects in python, which means that every item in the list can be replaced by any other value.

Thank you! I can't believe I never thought of using += <_<

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.