I'm having trouble with creating a function that takes an argument of a string and returns just the numbers in type str. My code looks something like this.:
def check_if_number(number_string):
for ch in number_string:
if ch.isdigit():
num = number_string[ch]
return num
print(check_if_number('1655t'), end='')
It should print: 1655
check_leap_yearfunction ? Also, what exact error you are getting ?numis just a single character,chis still a string you you need to convert that to anintafter checking, as you can't index with it. Are you trying to remove all non-digit characters or just check if the digit isn't only digits?