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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:29:37+00:00 2026-05-25T03:29:37+00:00

I have a list: test = [1, 2, 3, 4, 5, 6, 7, 8,

  • 0

I have a list: test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

Need to increase each list element in all possible ways using Python standard library. It’s a puzzle, and I’ve already done this:

test = [elem + 1 for elem in test]

for i in range(len(test)): test[i] += 1

test = map(lambda x : x + 1, test)

test = [sum(elem) for elem in zip(test, [1]*len(test))]

Any others ideas?

  • 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-25T03:29:38+00:00Added an answer on May 25, 2026 at 3:29 am

    You could use recursion, (and you could use True and False instead of 1 and 0, but that’s just crazy talk):

    def recurseadd(test):
        if test:
            return [test[False] + True] + recurseadd(test[True:])
        else:
            return test
    

    Instead of that + you could use [test[0] + 1].extend(recurseadd(test[1:])).

    You coud use operator.add instead of +, with functools.partial and itertools.imap if you wanted:

    from functools import partial
    from operator import add
    from itertools import imap
    
    addone = partial(add, 1)
    
    test = list(imap(addone, test))  # don't really use imap if you want a list
    

    You could use itertools‘s izip and repeat:

    test = [sum(elem) for elem in izip(test, repeat(1))]
    

    Another method with sum, inspired by Eren’s comment to GWW’s answer:

    test = sum(([x+1] for x in test), [])
    

    Yyou could use xrange instead of range, you could use itertools.count(1).next() to generate the 1s…

    There are an infinite number of minor variations, but your three plus the recursive version seem to cover the basic ones. Eren’s reduce version is nice too.

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

Sidebar

Related Questions

I have a test list that I am trying to capture data from using
I have a list of files like this: Test.(file1)[text].txt Test.(file2)[text].txt Test.(file3)[text].txt I need to
I have std::list<multimap<std::string,std::string>::iterator> > Now i have new element: multimap<std::string,std::string>::value_type aNewMmapValue(foo1,test) I want to
I have a string like this: TEST.DATA.Data.COR.Point,2;TEST.DATA.Data.COR.Point,5;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.WordTOFIND,18 I have a list of array with
I have this but I got an error: -- test if a list contains
I have the following: [list] [*] test [*] test [*] test [/list] and I
I have a list of test items, in the form of this: 8;SLEEP_MODE 15;KWP_CHKSUM
okay have a this list: object[] test; test[0]=null; .... test[8700]=null; test[8701]= object[] .... test[9431]=
It's difficult to say this right. Basically, I have a List, and I need
I have a List of classes in my collection like List<MyClass> test = new

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.