MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / str_eval

Function str_eval

project_euler/problem_008/sol3.py:60–73  ·  view source on GitHub ↗

Returns product of digits in given string n >>> str_eval("987654321") 362880 >>> str_eval("22222222") 256

(s: str)

Source from the content-addressed store, hash-verified

58
59
60def str_eval(s: str) -> int:
61 """
62 Returns product of digits in given string n
63
64 >>> str_eval("987654321")
65 362880
66 >>> str_eval("22222222")
67 256
68 """
69
70 product = 1
71 for digit in s:
72 product *= int(digit)
73 return product
74
75
76def solution(n: str = N) -> int:

Callers 1

solutionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected