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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:24:36+00:00 2026-06-15T22:24:36+00:00

for example, if i have a list like: one = [1,2,3] what function or

  • 0

for example, if i have a list like:

one = [1,2,3]

what function or method can i use to split each element into their own separate list like:

one = [1]

RANDOM_DYNAMIC_NAME = [2]

RANDOM_DYNAMIC_NAME_AGAIN = [3]

and at any given time, the unsplit list called one may have more than 1 element, its dynamic, and this algorithm is needed for a hangman game i am coding as self-given homework.

the algorithm is needed to complete this example purpose:

pick a word: mississippi

guess a letter: s

['_','_','s','s','_','s','s','_','_','_','_']

Here is my code:

http://pastebin.com/gcCZv67D

  • 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-15T22:24:38+00:00Added an answer on June 15, 2026 at 10:24 pm

    Looking at your code, if the part you’re trying to solve is the comments in lines 24-26, you definitely don’t need dynamically-created variables for that at all, and in fact I can’t even imagine how they could help you.

    You’ve got this:

    enum = [i for i,x in enumerate(letterlist) if x == word]
    

    The names of your variables are very confusing—something called word is the guessed letter, while you’ve got a different variable letterguess that’s something else, and then a variable called letter that’s the whole word… But I think I get what you’re aiming for.

    enum is a list of all of the indices of word within letterlist. For example, if letterlist is 'letter' and word is t, it will be [2, 3].

    Then you do this:

    bracketstrip = (str(w) for w in enum)
    

    So now bracketstrip is ['2', '3']. I’m not sure why you want that.

    z = int(''.join(bracketstrip))
    

    And ''.join(bracketstrip) is '23', so z is 23.

    letterguess[z] = word
    

    And now you get an IndexError, because you’re trying to set letterguess[23] instead of setting letterguess[2] and letterguess[3].

    Here’s what I think you want to replace that with:

    enum = [i for i,x in enumerate(letterlist) if x == word]
    for i in enum:
        letterguess[i] = word
    

    A few hints about some other parts of your code:

    You’ve got a few places where you do things like this:

    letterlist = []
    for eachcharacter in letter:
      letterlist.append(eachcharacter)
    

    This is the same as letterlist = list(letter). But really, you don’t need that list at all. The only thing you do with that is for i, x in enumerate(letterlist), and you could have done the exact same thing with letter in the first place. You’re generally making things much harder for yourself than you have to. Make sure you actually understand why you’ve written each line of code.

    “Because I couldn’t get it to work any other way” isn’t a reason—what were you trying to get to work? Why did you think you needed a list of letters? Nobody can keep all of those decisions in their head at once. The more skill you have, the more of your code will be so obvious to you that it doesn’t need comments, but you’ll never get to the point where you don’t need any. When you’re just starting out, every time you figure out how to do something, add a comment reminding yourself what you were trying to do, and why it works. You can always remove comments later; you can never get back comments that you didn’t write.

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

Sidebar

Related Questions

I have List where myObj has it own list of objects called example mySubObj.
How to sort list of date object ? For example I have unsorted list
Case example: I have a long list of items, and when I put my
Possible Duplicate: Java - Regex problem I have list of URLs of types: http://www.example.com/pk/etc
I have a list within a data frame (in this example, df$candpct ), and
I have a list of items lets say for example a, b, c. As
I have a List that contains items, for example: 1) https:\\10.12.23\\ 2) https:\\12.23.12.25\\ 3)
I have a list of numbers, for example: list=[10,50,90,60] I want to sorte the
Example of the problem If I have a list of valid option strings which
I have a method that queues some work to be executed asynchronously. I'd like

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.