Python exercises the calculation of all characters in the string Fu De and

Source: Internet
Author: User
The second problem: calculating all the numbers in a string and
1. Only lowercase letters and numbers in a string
2. Numbers may or may not be contiguous
3. Sequential numbers are treated as a number

s= ' 1234adg3g11 '
S1 = ""
For I in S:
If I.isdigit ():
S1=s1+i
Else
s1=s1+ ""
lt = S1.split ("")
m= 0
For a in LT:
If A.isdigit ():
M=m+int (a)
Print (m)

* Solve the idea: get the numbers out of the string, separate the numbers from the other characters with if else, and format the other characters and unify them to prepare for the next split. I didn't make it. The traversal of the split () function returns a list of the usages unfamiliar

Python exercises the calculation of all characters in the string Fu De and

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.