We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fed9345 commit bce2aa4Copy full SHA for bce2aa4
1 file changed
exercises/1000_programs/medium/1805_diff_integers.py
@@ -0,0 +1,27 @@
1
+def diff_integers_in_string(phrase: str) -> int:
2
+ """
3
+ Given a string phrase, return the number of different integers that appear in phrase.
4
+
5
+ Args:
6
+ phrase (str): The input string.
7
8
+ Returns:
9
+ int: The number of different integers that appear in phrase.
10
11
+ Example:
12
+ Input: "Smithech ha resuelto el issue #2595"
13
+ Output: 3
14
15
+ list_of_integers = set()
16
17
+ for char in phrase:
18
+ if char.isdigit():
19
+ list_of_integers.add(char)
20
21
+ return len(list_of_integers)
22
23
+if __name__ == "__main__":
24
+ example = "Smithech ha resuelto el issue #2595"
25
+ result = diff_integers_in_string(example)
26
+ print("Input: ", example)
27
+ print("Output: ", result)
0 commit comments