encoding and decoding in python

alphabet = ['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']

def caesar(start_text, shift_amount, cipher_direction):
  end_text = ""
  if cipher_direction == "decode":
    shift_amount *= -1
  for char in start_text:
    if char in alphabet:
      position = alphabet.index(char)
      new_position = position + shift_amount
      end_text += alphabet[new_position]
    else:
      end_text += char
  print(f"Here's the {cipher_direction}d result: {end_text}")


should_end = False
while not should_end:

  direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
  text = input("Type your message:\n").lower()
  shift = int(input("Type the shift number:\n"))
  shift = shift % 26

  caesar(start_text=text, shift_amount=shift, cipher_direction=direction)

  restart = input("Type 'yes' if you want to go again. Otherwise type 'no'.\n")
  if restart == "no":
    should_end = True
    print("Thanks for using me")
    

3.67
9
Krish 100200 points

                                    #novince coder, dont know if im doing this right XD
EncodingValues = ['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','!','@','$','%','^','&','*','(',')','_','+','-','=','#']
encode = "this"

def encode(string):
  encodedcode = ""
  LetterToEncode = 0
  for i in string:
    LetterToEncode = LetterToEncode + 1
    encodedcode = encodedcode + EncodingValues.index(LetterToEncode)
    encodedcode = encodedcode + " "
    #still editing this
  
def decode(string):
  decodedcode = ""
  LetterToDecode = 0
  for i in string:
    LetterToDecode = LetterTodecode + 1
    if string.index(letterToDecode + 2) = " "
    decodedcode = decodedcode + EncodingValues.index(LetterToDecode) 

3.67 (9 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
universal encoding/decoding python decode and encode python does .decode() work for any encoding python text encoding and decoding with python encode and decode string in python python encode and decode string what does decode do in python how to decode encoded string in python how to uncode and decode python how to do encoding and decoding in python encoding and decoding in python 3 encoding and decoding in python different encodings decoder file python python2 encoding and decoding decode a encoded python code file and run encoding decoding python project decode method python encode and decode text python decode encoding python python encoding and decoding puython decode string encoding decoding in python decoder in python decode the script using python encoders and decoders in python encoding and decoding python python decode encodings can we decode a string without knowing encoded format encode and decode in python module for encoding bytes in python encoding and decoding sentences python string coversion decode in pythgon how to deocde b'' data in python decode string \ python decode encoded string how to decode python python encode to decode decoding of text file in python python print decode python string encode and decode decode() string functions in python how to encode text and decode text in python how to encode text and decode text in python python decode string decode a string python encode decode python decode string python decode in python .decode in python python decode method python results.decode encode decode value python encoding and decoding strings in python decode encode scrip pythong what does it mean decode a data string decoding encoding script for pythong
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source