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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:03:16+00:00 2026-05-25T15:03:16+00:00

For instance, if I have a list of words: Words = [‘A’, ‘list’, ‘of’,

  • 0

For instance, if I have a list of words:

Words = ['A', 'list', 'of', 'words']

and want a second list to reference the lengths of those words, how could I achieve this? I’m aware that I could do something like:

Lengths = map(lambda w: len(w), Words)
[1, 4, 2, 5]

but I would have to continually call that function every time Words is altered.

  • 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-25T15:03:17+00:00Added an answer on May 25, 2026 at 3:03 pm

    You could use a class:

    class mywords:
        def __init__(self, a):
            self.words = a
            self.length = map(lambda w: len(w), a)
        def append(self, string):
            self.words.append(string)
            self.length.append(len(string))
    
    
    a = mywords(['A', 'list', 'of', 'words'])
    
    a.append("this")
    print a.words
    print a.length
    

    It’s the first time I use a class, so there might be a better way. However this seems to work well. You would need to define other methods for other operations such as insert, remove, etc.

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

Sidebar

Related Questions

I have two tables. First contain list of used words, second keep black list
i have written the next code: public void delete(MyType instance) { List<MyType> myList =
For instance, if I have an class: public class StuffHolder { List<Stuff> myList; public
I have a page-scoped component, which has an instance variable List with data, which
For instance I have a string like this : abc123[*]xyz[#]098[~]f9e [*] , [#] and
I have a list of stop words which contain around 30 words and a
We have a list of about 150,000 words, and when the user enters a
Let's say I have a list of words: resign resins redyed resist reeded I
Let's say I have a <ul> list: <ul class=products> ... </ul> I want to
I have a list of bad words in the database. Everytime a user submit

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.