#๐ I can't access the current item in for loop!!
31 messages ยท Page 1 of 1 (latest)
@civic sinew
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
for i, part in enumerate(Parts):
Length_Needed = Black_Frames[i][3]
Actual_length = Part_Lengths[i]
Length_Needed_To_Seconds = round(Timestamps_To_Seconds(Length_Needed), 3)
Actual_length_To_Seconds = round(Timestamps_To_Seconds(Actual_length),3)
if Actual_length_To_Seconds < Length_Needed_To_Seconds:
while Actual_length_To_Seconds < Length_Needed_To_Seconds:
if int(i) == len(Parts)-1:
New_Clip = random.choice(Parts[i-1])
else:
New_Clip = random.choice(Parts[i+1])
part.append(New_Clip)
New_Clip_Length = New_Clip[5]
Actual_length = Add_Timestamps(Actual_length, New_Clip_Length)
Actual_length_To_Seconds += Timestamps_To_Seconds(New_Clip_Length)
else:
pass
Hey @civic sinew!
It looks like you're trying to paste code into this channel.
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
but if I type Temp_Part = list(part) before the code, it works with Temp_Part
You're modifying the list while you iterate over it. Generally not a good idea but since you're appending, probably ok.
That may not be the error. please show the full traceback of the error.
What kind of object is part, the element from Parts ?
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
It's a numpy array
:incoming_envelope: :ok_hand: applied timeout to @civic sinew until <t:1733786272:f> (10 minutes) (reason: emoji spam - sent 39 emojis).
The <@&831776746206265384> have been alerted for review.
!unmute 448554538329309184
:incoming_envelope: :ok_hand: pardoned infraction timeout for @civic sinew.
!paste use our pastebin
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
the timestamps could potentially be interpreted as emojis, hence the mute
So: is this list the Parts list? It does not seem to be a numpy array?
Sorry, I've meant for another array, I messed it up.
This is the real one
I just fixed the issue, I don't know why the vscode doesn't color .append() in that case
it just works fine
So you know what was wrong?
I would guess that VSCode doesn't know wnough to know if .append is inappropriate. But I still don't know what Parts even looks like.
Good luck.
And the current code?
Unless your problem is fixed.
Colours in VSCode are from 2 sources: syntax highlighting, colouring keywords like if specially etc, and possibly linters, which look for "dubious" code in your programme. They can be very helpful, but they do not know your programme's intent and also often do not have enough context to infer some things. And they certainly do not highlight every error, particularly logic errors.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.