def removeDigits(str): return str.translate({ord(i): None for i in '0123456789'}) def fileinput(): with open('constant.txt') as f: lines = f.readlines() print('Initial string: ', lines) res = list(map(removeDigits, lines)) print('Final string: ', res) print('Make string upper or lower?') choice = input() if choice.upper() == 'UPPER': print(res.upper()) elif choice.lower() == 'lower': print(res.lower()) else: print('An error has occured') fileinput()
Initial string: ['Geeks123for127Geeks'] Final string: ['GeeksforGeeks'] Make string upper or lower? UPPER
res
map
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)