#🔒 how to make a loop

37 messages · Page 1 of 1 (latest)

calm yoke
#

I'm very new to coding and for an assignment I need to return a list of vertices that are dependant on some variables, I can meet all the parameters but my solution is a bit sloppy as instead of any loop, I have just typed a slightly different function for the vertex for the amount of maximum vertices required, could someone please explain how I could simplify this and have it be able to extend past 8 vertices? thank you.
list = [leftmost_vertex, (leftmost_vertex[0] + horizontal_gap_between_vertices, leftmost_vertex[1]), (leftmost_vertex[0] + 2horizontal_gap_between_vertices, leftmost_vertex[1]), (leftmost_vertex[0] + 3horizontal_gap_between_vertices, leftmost_vertex[1]), (leftmost_vertex[0] + 4horizontal_gap_between_vertices, leftmost_vertex[1]), (leftmost_vertex[0] + 5horizontal_gap_between_vertices, leftmost_vertex[1]), (leftmost_vertex[0] + 6horizontal_gap_between_vertices, leftmost_vertex[1]), (leftmost_vertex[0] + 7horizontal_gap_between_vertices, leftmost_vertex[1]), (leftmost_vertex[0] + 8*horizontal_gap_between_vertices, leftmost_vertex[1])]

slow elmBOT
#

@calm yoke

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.

short light
#

!close

calm yoke
#

is that a hint for me or a server command?

river wharf
#

crazy

#

!rule 5

slow elmBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

river wharf
#

but i’ll help you with looos

river wharf
slow elmBOT
#

10. Do not copy and paste answers from ChatGPT or similar AI tools.

river wharf
#

fuck i forgot

#

!ruke 6

#

!rule 6

slow elmBOT
#

6. Do not post unapproved advertising.

river wharf
#

NO

#

theres a rule about homework JES_Sad

#

!rule homework

slow elmBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

river wharf
#

there

calm yoke
#

oh, why is there a tag for it then?

#

my bad

river wharf
#

i’ll help w loops there

river wharf
calm yoke
#

sort of, but all the examples ive been given are not relavent to this and are about printing values from lists

#

none of them are about making lists so im having trouble understanding how to implement the loop functions

calm yoke
# slow elm

yeah i dont want an answer i just wanted some clues on what to implement

calm yoke
#

yeah so the code there makes a list of vertices up to the amount of vertices, so for the return i have: return list[0:number_of_vertices]

lofty vault
#

it might help to post the proper code

#

!code

slow elmBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

calm yoke
#

yeah i realised that, theyre just between every number and horizontal_gap_between_vertices, like 8*horizontal_gap_between_vertices

#

no other * apart from those ones

slow elmBOT
#
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.