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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:05:06+00:00 2026-06-01T19:05:06+00:00

I would isolate the last element of a tuple like a = (3,5,5) last

  • 0

I would isolate the last element of a tuple like

a = (3,5,5)
last = a[-1]

but the problem is that i have a pice ok code like this

if var == last:
  do something

and it takes the first 5 and not the second, how can i do to take the last one?

  • 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-01T19:05:07+00:00Added an answer on June 1, 2026 at 7:05 pm

    What you are trying to do is impossible. Those two fives are exactly the same.

    However, when iterating over the tuple you can check if you reached the last element like this:

    a = (3, 5, 5)
    for i, var in enumerate(a):
        if i == len(a) - 1:
            print 'last element:'
        print var
    

    Demo:

    In [1]: a = (3, 5, 5)
    In [2]: for i, var in enumerate(a):
       ...:     if i == len(a) - 1:
       ...:         print 'last element:'
       ...:     print var
       ...:
    3
    5
    last element:
    5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a view that is extended to several other views
I have an application that allows users to save events. I would like to
Apple clearly has this automated in some way, I would like to have access
I'd like to isolate a substring of a source code in ruby, but I
Using Watir I have been able to isolate this button element: <BUTTON id=authButton class=commandButton
I have some PNGs with transparent backgrounds that I would like to add shadows
Would a Python script like this be safe to use? There would be a
I would like to isolate a part of my responseText in Jquery and Ajax.
I would like to have domain.com using asp.net mvc2 technology and domain.com/blog would use
I would like to write a small piece of program that launches threads, consumes

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.