encoding and decoding in python

Solutions on MaxInterview for encoding and decoding in python by the best coders in the world

showing results for - "encoding and decoding in python"
Clara
16 Jan 2020
1alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
2
3def caesar(start_text, shift_amount, cipher_direction):
4  end_text = ""
5  if cipher_direction == "decode":
6    shift_amount *= -1
7  for char in start_text:
8    if char in alphabet:
9      position = alphabet.index(char)
10      new_position = position + shift_amount
11      end_text += alphabet[new_position]
12    else:
13      end_text += char
14  print(f"Here's the {cipher_direction}d result: {end_text}")
15
16
17should_end = False
18while not should_end:
19
20  direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
21  text = input("Type your message:\n").lower()
22  shift = int(input("Type the shift number:\n"))
23  shift = shift % 26
24
25  caesar(start_text=text, shift_amount=shift, cipher_direction=direction)
26
27  restart = input("Type 'yes' if you want to go again. Otherwise type 'no'.\n")
28  if restart == "no":
29    should_end = True
30    print("Thanks for using me")
31    
Mira
07 Mar 2019
1#novince coder, dont know if im doing this right XD
2EncodingValues = ['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Z','X','C','V','B',',','N','M','!','@','$','%','^','&','*','(',')','_','+','-','=','#']
3encode = "this"
4
5def encode(string):
6  encodedcode = ""
7  LetterToEncode = 0
8  for i in string:
9    LetterToEncode = LetterToEncode + 1
10    encodedcode = encodedcode + EncodingValues.index(LetterToEncode)
11    encodedcode = encodedcode + " "
12    #still editing this
13  
14def decode(string):
15  decodedcode = ""
16  LetterToDecode = 0
17  for i in string:
18    LetterToDecode = LetterTodecode + 1
19    if string.index(letterToDecode + 2) = " "
20    decodedcode = decodedcode + EncodingValues.index(LetterToDecode) 
queries leading to this page
decode encode scrip pythongwhat does decode do in pythonencoding decoding in pythonhow to decode encoded string in pythonencoder decoder architecture pythoncan we decode a string without knowing encoded formatwhat is encode and decode in python decode in pythonwhat does it mean decode a data stringencode and decode text pythonstring coversion decode in pythgonhow to encode text and decode text in pythondoes decode 28 29 work for any encoding pythonencoding and decoding in pythonhow to do encoding and decoding in pythonpython string encode and decodedecoding with pythonencoding and decoding in python 3python decodepython decode encodingspython encode and decode stringdecoder in pythonpython print decodedecode in pythonencoding decode pythondecode and encode in pythondecode method pythondecode string pythonstring encoding and decoding in python 3encode and decode python stringsuniversal encoding 2fdecoding pythonencoding and decoding pythonpython results decodehow to uncode and decode pythonmodule for encoding bytes in pythontext encoding and decoding with pythonencoding and decoding sentences pythonencode and decode string in pythonencoding and decoding strings in pythonstr decode pythonpython encode to decodepuython decode stringencode decode pythondifferent encodings decoder file pythondecode the script using pythonencoders and decoders in pythonpython2 encoding and decodingpython encoding and decoding with a key modulepython encoding and decoding moduledecode string 5c pythonpython encoding and decodingdecode encoded stringdecode encoding pythondecode 28 29 string functions in pythondecode function in pythonpython decode methoddecoding encoding script for pythongdecode and encode pythondecode any encoding format using pythonstring decoding pythonhow to deocde b 27 27 data in python decode 28 29 python encodingsencoding decoding python projectdecode a string pythonencode decode value pythonencode and decode in pythonpython decode stringhow to decode pythondecode a encoded python code file and runhow to encode text and decode text in pythondecoding of text file in pythonencoding and decoding in python