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])]
#🔒 how to make a loop
37 messages · Page 1 of 1 (latest)
@calm yoke
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.
!close
is that a hint for me or a server command?
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
but i’ll help you with looos
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
there
i’ll help w loops there
have you learnt loops before?
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
making lists?
hold on brb
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]
your code paste here failed because of discord formatting, * characters turned some text italic
it might help to post the proper code
!code
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
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.
