Skip to content

Latest commit

 

History

History
43 lines (23 loc) · 654 Bytes

Numbers_in_strings.md

File metadata and controls

43 lines (23 loc) · 654 Bytes

CodeWars Python Solutions


Numbers in strings

In this Kata, you will be given a string that has lowercase letters and numbers. Your task is to compare the number groupings and return the largest number.

For example, solve("gh12cdy695m1") = 695, because this is the largest of all number groupings.

Good luck!


Given Code

def solve(s):
    pass

Solution

def solve(s):
    for c in s:
        if c.isalpha():
            s = s.replace(c, " ")
    return max([int(i) for i in s.split(" ") if i != ""])

See on CodeWars.com