Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6707987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:42:18+00:00 2026-05-26T07:42:18+00:00

I am making a program that takes a sentence and garbles it, until run

  • 0

I am making a program that takes a sentence and garbles it, until run through a “degarbler”

Theres probably a better way to do this, but I would appreciate it if everyone would show me how to fix what I am doing wrong

def sencoder (sentence):
    sentence = sentence.replace ("a","h")
    sentence = sentence.replace ("s","j")
    sentence = sentence.replace ("d","k")
    sentence = sentence.replace ("f","l")
    sentence = sentence.replace ("b","g")
    sentence = sentence.replace ("z","t")
    sentence = sentence.replace ("q","y")
    sentence = sentence.replace ("w","u")
    sentence = sentence.replace ("e","i")
    sentence = sentence.replace ("r","o")
    sentence = sentence.replace ("x","p")
    sentence = sentence.replace ("c","b")
    sentence = sentence.replace ("v","n")
    sentence = sentence.replace ("m","m")
    print sentence

def decoder (sentence):
    sentence = sentence.replace ("h","a")
    sentence = sentence.replace ("j","s")
    sentence = sentence.replace ("k","d")
    sentence = sentence.replace ("l","f")
    sentence = sentence.replace ("g","b")
    sentence = sentence.replace ("t","z")
    sentence = sentence.replace ("y","q")
    sentence = sentence.replace ("u","w")
    sentence = sentence.replace ("i","e")
    sentence = sentence.replace ("o","r")
    sentence = sentence.replace ("p","x")
    sentence = sentence.replace ("b","c")
    sentence = sentence.replace ("n","v")
    sentence = sentence.replace ("m","m")
    print sentence

sentence = ""
choice = raw_input ("Do you want to decode or encode: ").lower()   
while sentence != "quit":
    sentence = raw_input("Enter the code: ")
    if choice == "encode":
        decoder(sentence)
    elif choice == "decode":
        sencoder(sentence)
    else:
        print "Please make a valid decision"

help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:42:19+00:00Added an answer on May 26, 2026 at 7:42 am

    Here is a hint: Use the translate method instead.

    >>> import string
    
    >>> t = string.maketrans("abcdef", "bcdefa")
    >>> "abracadabra".translate(t)
    'bcrbdbebcrb'
    
    >>> t2 = string.maketrans("bcdefa", "abcdef")
    >>> "bcrbdbebcrb".translate(t2)
    'abracadabra'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a program that retrieves decently large amounts of data through a python
Im am making an Java SWT program that is required to run on both
I'm making a simple form that is to step through a program iteratively. How
I'm making a program that takes a snapshot of the screen, and saves it
I'm making a program that takes names from the user seperated by commas. The
Im making an application that uses of API-threads in C, The program takes N-files
I'm making a Java program that takes some text as input, and has to
I'm making this function that takes a string input, converts it to an int,
I'm making a program that takes a three-digit integer and splits it into two
I'm making a simple program that takes text entered in a text box, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.