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 8874551
In Process

The Archive Base Latest Questions

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

The code was too long to past here, so it’s on PasteBin: http://pastebin.com/UDPFYsLJ What

  • 0

The code was too long to past here, so it’s on PasteBin: http://pastebin.com/UDPFYsLJ

What I want to happen is to be able to put in something like “555-GET-FOOD” and get “555-438-3663”.

I have the code changing the letters to numbers…just on completely different lines. Here’s a small excerpt:

Number:  555-GET-FOO3
Number:  555-4ET-FOOD
Number:  555-GET-3OOD

It’s changing the letters correctly and leaving the numbers alone, but it’s all on different lines. I know I have it running in a for loop, but I want the changes made to the previous loop to stay with the current loop.

For example, if the first loop returns 555-GET-FOO3, I want the next loop to pick that up so that it could return 555-4ET-FOO3.

I’m just not sure how to do that.

Any tips would be great. I’ve also been looking over this thread: Removing a list of characters in string

However, I haven’t done much (or, well, anything) with the translate function and am having a hard time finding a good walkthrough outside of the Python Docs.

This is for school and we can’t use Python 3, we have to use Python 2.7, so I don’t think maketranslate will work.

  • 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-14T18:45:00+00:00Added an answer on June 14, 2026 at 6:45 pm

    All you have to do is change this

    for i, j in dict.iteritems():
        newNumber = phoneNum.replace(i, j)
        print "Number: ",newNumber
    

    to this:

    for i, j in dict.iteritems():
        phoneNum = phoneNum.replace(i, j)
        print "Number: ",newNumber
    

    Explanation:

    In your method, you replace some characters in the original phone number and assign the result to a new variable called newNumber. But then, you do nothing with newNumber, so it gets thrown away.

    Instead, if you overwrite the input (phoneNum) with the result of the translation, then any new translations that you make will be made with the newly overwritten value of phoneNum, thereby making all changes cumulative

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

Sidebar

Related Questions

I think I have been working on this code too long. Anyway here is
my code is too long so sorry :) @model IEnumerable<Osos11.Models.Customers> @Html.DevExpress().GridView( settings => {
i've been creating functions for too long without taking my code to 'classes'. I
Its too much code to paste here so, I have created demo please have
I'm sort of stuck on a UIAlertViewStylePlainTextInput. (My code is too long to post
First of all forgive me, but the code was too long and copied from
I have stared at this short code too long, and cannot for the life
I think I have been staring at this code too long and I am
Been looking at this code for too long and I am getting gloomy any
Is there any replacement for z-index? My code is too long, thus I will

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.