Python Forum
how to decode this in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to decode this in python
#1
hi, im fairly new to python and i was wondering how i could finish this code:

import random

def encode_text (text):
    random.seed (0)

    enc_text = ''

    for ch in text:
        enc_number = random.randint (0, 2)
        enc_char = chr(ord (ch) + enc_number)
        enc_text += enc_char
    return enc_text


def decode_text (text):
   
    dec_text = ''

# Add code to decode the message that was encoded wint enccode_text (text) function

    return dec_text
the code above would be imported into the following:

import enc_function


text = 'Uie!svjdl!drqwo fqy"lwmqs"oxfs"tif!ncz{!eqh'

print ("Original string: ", enc_function.decode_text (text))
Reply


Messages In This Thread
how to decode this in python - by anthoniegallego - Apr-07-2019, 07:39 PM
RE: how to decode this in python - by Yoriz - Apr-07-2019, 08:00 PM
RE: how to decode this in python - by Yoriz - Apr-07-2019, 08:12 PM
RE: how to decode this in python - by Yoriz - Apr-07-2019, 08:15 PM
RE: how to decode this in python - by ichabod801 - Apr-07-2019, 08:17 PM
RE: how to decode this in python - by Yoriz - Apr-07-2019, 08:21 PM
RE: how to decode this in python - by Yoriz - Apr-07-2019, 08:30 PM
RE: how to decode this in python - by loomski - Apr-08-2019, 08:45 PM
RE: how to decode this in python - by Yoriz - Apr-07-2019, 09:06 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020