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

  • Home
  • SEARCH
  • 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 8869267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:26:59+00:00 2026-06-14T17:26:59+00:00

Winkleson here with another question for a http://singpath.appspot.com problemset question. I am a beginner

  • 0

Winkleson here with another question for a http://singpath.appspot.com problemset question. I am a beginner programmer who would like some guidance whenever I can. Anyways I came up to this question here and I am not sure how to proceed without wasting time by comparing EVERY.SINGLE.LETTER. in if statements. So I would love any hints/solutions to cut down on the coding for this question. I’ll post what I have so far (not much). Thanks in advance!

Question:


Substitution Encryption

Create a program that can be used to encrypt
and decrypt a string of letters. The function should take input of a
string to encode and a string of letters giving the new order of the
alphabet. The second string contains all characters of the alphabet
but in a new order. This order tells what letters to swap. The first
letter in the second string should replace all the a’s in the first
string. The third letter of the second string should replace all c’s
in the first string. Your solution should be in all lower case. Be
careful of punctuation and digits (these should not change).

Examples (calls):

>>> encrypt('hello banana','qwertyuiopasdfghjklzxcvbnm')
'itssg wqfqfq'

>>> encrypt('itssg wqfqfq','kxvmcnophqrszyijadlegwbuft')
'hello banana'

>>> encrypt('gftw xohk xzaaog vk xrzxnkh','nxqlzhtdvfepmkoywrjiubscga')
'this code cannot be cracked'

>>> encrypt('mkhzbc id hzw pwdh vtcgxtgw ube fbicg ozth kbx tew fbicg','monsrdgticyxpzwbqvjafleukh')
'python is the best language for doing what you are doing'

My code:


def encrypt(s, realph):
    
    alph = 'abcdefghijklmnopqrstuvwxyz' #Regular Alphabet
    news = '' #The decoded string   
        
    #All comparison(s) between realph and alph    
        
    for i in range(len(realalph)):        
        
        #Comparison Statement here too.
        news = ''.join(alph) 
    
    return news

As you can see this is obviously the equivalent to failed pseudocode… As always any suggestions and/or solutions would be amazing! Thanks in advance! – Winkleson

  • 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-06-14T17:27:00+00:00Added an answer on June 14, 2026 at 5:27 pm

    Here’s a translation solution.

    from string import maketrans
    
    def encrypt(s, scheme):
        alphabet = 'abcdefghijklmnopqrstuvwxyz'
        translation = maketrans(alphabet, scheme)
        return s.translate(translation)
    

    Strings have a built in translate method allowing you to switch single letters out with other letters. Incredibly snappy, and quite useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Winkleson here! I am currently learning Python when I got stuck on a problem.

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.