Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Explicit index position values

Is there a way to reference N[-1] without calculating the value of -1?
If you want the index number of the last index the easiest method is:

last_index = len(N) - 1

If you need the element at the last index then just use the negative index:

last_element = N[-1]

If I misunderstood the question please clarify.
Software Engineer for Hire. White-hat only. DM Me.
Sorry let me clarify.

I have a for loop that counts iterations of natural numbers, so N[set(), set(set()), set(set(set())), ect]

I’m trying to reference the last position in this index without actually calling the value of N[-1]…

N[1] should be == N[set()] at that point.
(Dec 2, 2021 12:05 PM)simmer Wrote:  Sorry let me clarify.

I have a for loop that counts iterations of natural numbers, so N[set(), set(set()), set(set(set())), ect]

I’m trying to reference the last position in this index without actually calling the value of N[-1]…

N[1] should be == N[set()] at that point.

I feel like this isn't the way to approach whatever problem you are trying to solve, you generally want to be able to use N[-1]. Could you give more details about the entire problem you are solving and not the issue you're having? Perhaps there is a better approach.
Software Engineer for Hire. White-hat only. DM Me.
I’m not sure I understand the difference between an issue I’m having and the problem I’m solving

I mean I’m trying to calculate N[float(‘inf’)] to equate it to a formula?

What kind of rhetoric are you looking for?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Source] by HackersNov 19, 2024 01:51 PM 15 686 Nov 19, 2024 01:51 PM
Last Post: Hackers
[Release] by kunsDec 29, 2023 03:29 PM 0 146 Dec 29, 2023 03:29 PM
Last Post: kuns
[Release] by kunsDec 29, 2023 03:28 PM 0 133 Dec 29, 2023 03:28 PM
Last Post: kuns