#๐Ÿ”’ Idk how to explain

22 messages ยท Page 1 of 1 (latest)

prime crown
#

How do i type my code in here so i can explain it?

shut briarBOT
#

@prime crown

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.

prime crown
#

I have an excel sheet thats put into a list called data im using the __str method to return a str...duh, def __str__(self): if self.medal !="NA": return f'{self.season} {self.year} - {self.name} won {self.medal} in {self.event}' else: return f'{self.season} {self.year} - {self.name} didint win anything in {self.event}' then I have for n in range(len(data[1:6])): #new parameters but from a smaller range to print off my __str__ method, I just did the first 3 for convience s = Result(data[n][0], data[n][1], data[n][2], data[n][3], data[n][4], data[n][5], data[n][6], data[n][7], data[n][8], data[n][9], data[n][10]) print(s) why when i change for n in range(len(data[1:6]) lets say the 1 to a 2, I would think it would go down the excel sheet one more spot from the begging. but not matter what is still returns the top row

shut briarBOT
#

Hey @prime crown!

It looks like you pasted Python code without syntax highlighting.

Please use syntax highlighting to improve the legibility of your code and make 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.
prime crown
#

heres the out put returning the top row when its 1

#

here it is when i move it to 2

#

still returns the top row?

#

you can see about that for loop where im appending everything into a list i use data[1:] to only index everything from index 1 and down

#

if this is confusing i could probably explain it better sharing my screen in a call

#

heres the excel sheet

floral vigil
#

You're counting n for the size of data[1:6], but you're still indexing data[n]. You probably want for n in range(1:6). You need to do your indexing from 1.

wary chasm
#

rather, you should not be indexing at all

floral vigil
#

range(len(data[1:6])) is effectively range(0,5).

wary chasm
#
for row in data[1:6]: ...
#

also look into the spread operator

#

||```py
for row in data[1:6]:
print(Result(*row))

prime crown
#

thanks boyyss

#

at this point ima have to pay cameron

shut briarBOT
#
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.