#๐Ÿ”’ are there any bugs inside of my code? (i dont recommend reading it, it has no comments)

48 messages ยท Page 1 of 1 (latest)

limber cedar
#

just test by running it if you want to

formal steepleBOT
#

@limber cedar

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.

limber cedar
#

!

#

!post

#

!paste

formal steepleBOT
#
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.

limber cedar
ancient gyro
#

I dont believe so

cerulean rover
#

i dont recommend reading it, it has no comments
Comments are really not necessary here. The code is very easy to read, which is great! The only thing that gets in the way is its cyclomatic complexity, but at this level, it doesn't need anything more.

wheat lynx
# limber cedar just test by running it if you want to

that is the opposite of what people should be doing
no one should be executing/running code that they get from some random person on the internet without understanding the code, especially not after such a statement

limber cedar
#

iv never read it tho

limber cedar
limber cedar
wheat lynx
limber cedar
#

whats a data structure

wheat lynx
limber cedar
#

i just started two days ago

wheat lynx
#

you are already constructing simple data structures in the form of tuples right now in the code, but you could make them a little bit more structured and not have to repeat you code so much

wheat lynx
limber cedar
#

side question, are dictionaries just meant for keeping organized code? that way you can just use the key of it and with that get the value

wheat lynx
#

have you programmed in any other language before?

limber cedar
#

i learned a bit of lua over like a week by just watching tutorials mostly

#

i already know some basic concepts, and i decided i liked programming recent;y so i decided to learn python

wheat lynx
limber cedar
#

i wanted to make a chat bot next. would using a dictionary be better then making a bunch of tuples

wheat lynx
limber cedar
#

im going to spend this week learning everything about basic concepts, then i want to try moving on to intermediat stuff

wheat lynx
limber cedar
#

alright

wheat lynx
limber cedar
#

i want to try giving it combined resposnes, and a limit system so that it doesnt repeat itself after saying one thing once (like hello)

wheat lynx
limber cedar
#

also fix the feedback messages

wheat lynx
#

a good exercise would be to build upon this c9de and improve it step by step when you learn new things that you can apply to this code

hexed zealot
#

Anyone else mention that every question responds with either

print("Correct! a conditional is checking if things are (any operator) to other things.")
``` or
```py
print("Wrong! a conditional is checking if things are (any operator) to other things. ")
``` ?
wheat lynx
hexed zealot
#

So yeah, if you started with some structure like

data = [
    {
        "question": "What are data types?",
        "answers": ["int", "float", "str", ...],
        "final": "Data types include int, str, float, ...",
    },
    ...
]
``` then you could have one object per type of question you want to ask, you randomly select that object, and then work from it dynamically.
You don't need to know ahead of time how many possible answers there are per-question, you don't need new variables, and everything stays together.
```py
challenge = random.choice(data)
response = input(challenge["question"])
if response in challenge["answers"]:
    result = "Correct!"
else:
    result = "Wrong!"
print(f"{result} {challenge['final']}")
#

Just build on from there, take note of the number of answers you have (len(challenge["answers"])) if you want that, and so on.

#

this This would be my approach to DRYing up the code, as an example. Recognize the patterns that are in the code you have, and distill that down to simpler code with less repetition.
The smaller and less repetitive it is, the more unique features you can have in there.

formal steepleBOT
#
Python help channel closed for inactivity

This help channel has been closed. 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.