How to extract all the numbers in a string?
For example, consider a string "66,55,66,57". I want to extract each numbers into separate variables and perform integer arithmetic.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use a list comprehension along with
str.splitto break up the string and convert it to integers:Then you can do whatever you want with that list. For example: