How to process a String input including single quotation
I wrote a script by python which prompts users to Enter a string, then
encode or decode it. However, one of the users Entered single quotation(
this -> ' ) so the script stopped. How can I solve this problem. I would
like to accept single quotation as an input. the script looks like this:
while True:
input = raw_input('Enter a word or sentence')
if input == 'done':break
n = raw_input('Enter an encode number')
print encode(input,n) #this function encodes the input by n and
returns encoded words
There are ord and chr function in the encode function.
No comments:
Post a Comment