I want that my function returns encoding. User should import it. However, if a user hits enter, the function should return windows-1250 as default encoding.
When I run this code I get an error:
if enc == '': ^ IndentationError: unexpected indent
def encoding_code(prompt):
"""
Asks for an encoding,
throws an error if not valid encoding.
Empty string is by default windows-1250.
Returns encoding.
"""
while True:
enc = raw_input(prompt)
if enc == '':
enc = 'windows-1250'
try:
tmp = ''.decode(enc) # Just to throw an error if not correct
except:
print('Wrong input. Try again.')
continue
break
return enc