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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:33:05+00:00 2026-06-02T05:33:05+00:00

I feel like I am doing something wrong with the for loop and the

  • 0

I feel like I am doing something wrong with the for loop and the user input

Whenever I do the for loop, I do believe that the local variable in the for loop has only one entry in the list

list[index_int] #returns value of the indexed entry in the list
user_input = "1234"
user_input[-1] >>> 4


    def print_numbers(n):
    for entry in n:
        if entry == "1":
            if (entry == n[-1]):
                print "E"
            else:
                print entry + "s,",
        elif entry == "0":
            if (entry == n[-1]):
                print "X"
            else:
                print entry + "X,",
        else:
            if (entry == n[-1]): #applies if entry is equal to the value of user input       at index value of (-1), which I do not want
                print entry + "L"
            else:
                print entry + "s,",            
user_input = raw_input()
if user_input.isdigit():
    print_numbers(user_input)
else:
    print user_input

When I wanted to put down 101 or 212, I get these

Intention -> 1s, X, E
Result:
E
X, E

Intention -> 2s, 1s, 2L
Result:
2L 
1s, 2L

I do believe that the cause is that during the for loop, each variable has only one element in its own list.

Is there not a way to check if the for loop is AT the list’s (the string’s) last index position (NOT having the variable equal to the value of the string’s index i.e entry == n[-1])?

  • 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-02T05:33:06+00:00Added an answer on June 2, 2026 at 5:33 am

    You’re looking for enumerate(). And a bit more, but you should be able to figure that part out.

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

Sidebar

Related Questions

So I'm getting started with Git, and I feel like I'm doing something wrong.
I am using jaxb for my application configurations I feel like I am doing
I feel like this is something I should already know, but I'm just not
I feel like this is easy but I am missing something... Using jQuery, I
I feel like I must be missing something completely obvious, but I don't see
I feel like this should be a no brainer, but clearly I'm missing something...
I feel like I am missing something - from what it seems, JSP comes
I'm pretty sure I'm doing something wrong, but I've simplified my example as much
Is there a better way to do this? I feel like I am doing
I feel like GUID/UUID questions have been done to death here, but I can't

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.