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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:33:58+00:00 2026-05-25T14:33:58+00:00

This is a simple example of what I am trying to do. Say, I

  • 0

This is a simple example of what I am trying to do.
Say, I have a random list which is the following:

aa = 1
b = 2
c = 3
ao = 4
uw = 5
d = 6 
ih = 7

I give the input to the program as:

b d aa aw ay c

In the input there are strings which don’t have values and are not present in the list like ‘aw’ and ‘ay’. So, I have to change them into the strings which are present in the list. But the problem is, ‘aw’ and ‘ay’ are the combination of two strings. For example, I have to change ‘aw’ as ao + uw and ‘ay’ as ao + ih and form a list. So the new list of the input should be like,

b
d
aa
ao
uw
ao
ih
c

And the final output should be their corresponding values which is,

2 6 1 4 5 4 7 3  

I could not write this in code. Could someone help please? Thank you.

  • 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-25T14:33:59+00:00Added an answer on May 25, 2026 at 2:33 pm

    How about …

    str_converter = {'aa': 1, 'b':2, 'c':3, 'ao': 4, 'uw':5, 'd':6, 'ih':7}
    pre_converter = {'aw': ['ao', 'uw'], 'ay': ['ao', 'ih']}
    
    input = ['b', 'd', 'aa', 'aw', 'ay', 'c']
    
    work_list = []
    
    for in_string in input:
        converted_str = pre_converter.get(in_string)
        if converted_str is None:
            work_list.append(in_string)
        else:
            work_list.extend(converted_str)
    
    for work_string in work_list:
        print str_converter.get(work_string)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:
I have some simple example WinForms code which I am trying to translate into
I am trying this simple tutorial from oracle : http://www.oracle.com/technetwork/java/socket-140484.html (the Example 1 ).
Consider this simple example (which displays in red): echo -e \033[31mHello World\033[0m It displays
I have this simple example I can't seems to get working : MERGE INTO
Have a look a this simple example. I don't quite understand why o1 prints
I've created this simple example program, but this doesn't work. it won't connect. any
Stuck trying to figure out the best algorithm here. I have this simple function
I have something very similar to this example: https://developers.google.com/maps/documentation/javascript/examples/directions-simple All I am trying to

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.