#๐Ÿ”’ How to use an array instead of sets

63 messages ยท Page 1 of 1 (latest)

knotty ermineBOT
#

@tropic ginkgo

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.

tropic ginkgo
#

oh my text got deleted

fresh valley
#

!paste

knotty ermineBOT
#
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.

tropic ginkgo
#

im new to python, im learning through school and i was assigned to create a quiz program and i have to use arrays instead of sets

fresh valley
#
yes = {'yes','y','YES','Y','Yes'}

this is a set literal

tropic ginkgo
#

yes

tropic ginkgo
#

i think?

#

i have no idea whats an array

fresh valley
#

they probably mean list

tropic ginkgo
#

i think i can show a teacher example of their array

#

one sec

charred yarrow
#

you can pretty much use lists, there is no need for sets

fresh valley
#

there is no array in builtins

tropic ginkgo
#

but there was something that i was programming inefficiently

#

like 3x the amount of code

charred yarrow
#

also you dont need to import time whenever you want to wait 1 second

tropic ginkgo
#

ah yeah i dont but

#

i jus add it in

fresh valley
#

import time once at the very top of the script

tropic ginkgo
#

oh

charred yarrow
#

you can do these ifs/elifs more efficient

fresh valley
#

ew

tropic ginkgo
#

yeah

fresh valley
#

why are you using that font

tropic ginkgo
#

thats what he was talking about

fresh valley
tropic ginkgo
#

my teacjer

charred yarrow
tropic ginkgo
#

Then write

fresh valley
tropic ginkgo
#

It helps reduce

#

Code

#

could u give me a example

fresh valley
#

we don't really know what your teacher wants, as we are not your teacher

fresh valley
#

Did you mean to reply to OP?

tropic ginkgo
#

he asks to make the program to be written more efficiently like those elifs and ifs

tropic ginkgo
tropic ginkgo
#

Make the algorithm flow chart first

fresh valley
charred yarrow
tropic ginkgo
fresh valley
#

you also have some bugs in your code

#

such as line 76

tropic ginkgo
#

oh i see

#

i prob confused myself and did typo

fresh valley
#

also your ready thing does not seem to function properly

#

first of all, the program continues no matter if the user is considered ready or not

#

you also say "any input", but simply pressing enter will give empty string, which is falsy

tropic ginkgo
#

oh

#

I'll just put import to the top of the script in that case

fresh valley
#

that is completely unrelated to what I just said, but yes you should do that with the time import

#

in all future scripts that you write, all imports should go at the top

tropic ginkgo
fresh valley
#

๐Ÿค”

knotty ermineBOT
#
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.