-2

I have a working function that takes an input as string and returns a string. However, I want my function to return an empty string ("") if the input contains any number in whatever position in the string.

For example :

>>> function("hello")

works fine

>>> function("hello1")

should return ""

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61

1 Answers1

0

The main thing you need for that is the method "isdigit()" that returns True if the character is a digit.

For example:

yourstring="hel4lo3"
for char in yourstring:
  if char.isdigit():
    print(char)

Will output 4 and 3.

I think it is a good exercise for you trying to do your code from that!