I am a beginner in Python and I want to remove all Capital numbers from the string. I have tried below code but getting None after each function call. What should I return from the function?
def remove_capitals(a_string):
for latter in a_string:
if not (ord(latter) in range(65,91)):
print(latter,end="")
else:
continue
print(remove_capitals("A1B2C3D"))
print(remove_capitals("Georgia Institute of Technology"))
I am getting below Output
123None
eorgia nstitute of echnologyNone
else: continueis pointless at the end of a loop.returnstatement so it returns the defaultNone. if theprinthappens inside the function, remove it from outside and just doremove_capitals("A1B2C3D"). Otherwise, instead of printing inside, return it and print it outside.,prints(), then returnsNone. You then print that return value.print()calls aroundremove_capitals().