try:
sum(int(y) for y in var.split())
>> 20
More Related Contents:
- Is there a way to ordinate numbers in a list?
- Python list doesn’t reflect variable change
- Variable assignment and modification (in python) [duplicate]
- Function changes list values and not variable values in Python [duplicate]
- Dynamic variable in Python [duplicate]
- Assigning values to variables in a list using a loop
- How to assign each element of a list to a separate variable? [duplicate]
- Turn a single number into single digits Python [duplicate]
- convert string to list [duplicate]
- Printing the number from a list and its square on the same line in python3 [closed]
- How to reverse a list?
- How does assignment work with list slices?
- Why does Python skip elements when I modify a list while iterating over it?
- Count frequency of words in a list and sort by frequency
- Can’t modify list elements in a loop [duplicate]
- How do I make a flat list out of a list of lists?
- How to check if type of a variable is string?
- python class instance variables and class variables
- How to efficiently compare two unordered lists (not sets)?
- Add list to set
- Converting a list of tuples into a dict
- str.startswith with a list of strings to test for
- Python Array Slice With Comma?
- How to split strings inside a list by whitespace characters
- Python range() and zip() object type
- Python: find closest string (from a list) to another string
- How to override the slice functionality of list in its derived class
- How do I merge multiple lists into one list? [duplicate]
- Python: filtering lists by indices
- Creating a list in Python with multiple copies of a given object in a single line