#๐Ÿ”’ Bug index out of range

31 messages ยท Page 1 of 1 (latest)

verbal patioBOT
#

@cunning hawk

Python help channel opened

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.

cunning hawk
#

TEST FUNCTION: test_plot

DO NOT REMOVE THE LINE ABOVE

import matplotlib.pyplot as plt

Function to convert seconds to milliseconds

def seconds_to_milliseconds(seconds):
return seconds * 1000

x = 1988
seconds = 10.49
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:red", markersize=10)
x = 2021
seconds = 10.54
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:green", markersize=10)
x = 2023
seconds = 10.57
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:red", markersize=10)
x = 2021
seconds = 10.60
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:green", markersize=10)
x = 2009
seconds = 10.64
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:red", markersize=10)

verbal patioBOT
#

Hey @cunning hawk!

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.
cunning hawk
#
### TEST FUNCTION: test_plot
# DO NOT REMOVE THE LINE ABOVE
import matplotlib.pyplot as plt

# Function to convert seconds to milliseconds
def seconds_to_milliseconds(seconds):
    return seconds * 1000
    
x = 1988
seconds = 10.49
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:red", markersize=10)
x = 2021
seconds = 10.54
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:green", markersize=10)
x = 2023
seconds = 10.57
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:red", markersize=10)
x = 2021
seconds = 10.60
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:green", markersize=10)
x = 2009
seconds = 10.64
milliseconds = seconds_to_milliseconds(seconds)
coordinate = (x, milliseconds)
plt.plot(x, milliseconds, '.', color="tab:red", markersize=10
stuck hull
#

!traceback

verbal patioBOT
#
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.

stuck hull
#

If its really long, use a pastebin

#

!pastebin instructions below ๐Ÿ‘‡

verbal patioBOT
#
Pasting large amounts of code

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.

cunning hawk
#

File "/tmp/ed-test-marker.py", line 133, in main
result = tf(ctx)
^^^^^^^
File "/tmp/ex_autograder.py", line 30, in test_plot
if len(line) > 0 and line.strip()[0] is not '#':
~~~~~~~~~~~~^^^

stuck hull
#

That error doesn't make sense to me. Can you share a full screenshot of the autograder with your code and what its testing with?

uncut gorge
#

You don't show the code that gives the error

cunning hawk
#

one second

cunning hawk
#

its not even a line 133

#

so idk where tf its getting that from but the string index thing doesn't make any since to me either

stuck hull
#

thats by the autograder/marker

cunning hawk
#

?

#

the error yea

stuck hull
#

Backup your code somewhere and reset your exercise book

#

Can you show me what it looks like initially?

cunning hawk
#

blank it just looks like this

stuck hull
#

i see

cunning hawk
#

ive even sent the code over to my friends to test out and there getting the same error too

#

i feel like that this works but just not the way the auto grader wants it

stuck hull
#

I have no idea

verbal patioBOT
#
Python help channel closed

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.