#๐Ÿ”’ function is not returing a variable. when it meant to do that.

49 messages ยท Page 1 of 1 (latest)

subtle rockBOT
#

@vague gate

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.

vague gate
#

im posting the screenshot for context in case if something is wrong with indents which i dont understand how work

wide imp
#

can you paste the code instead, my sight is really crap

vague gate
#

def another_letter(chosen_word):
letter_counts = Counter(chosen_word)
predicted_letters = []
for letter, count in letter_counts.items():
if count > 1:
predicted_letters.extend([letter] * (count - 1))
return predicted_letters

subtle rockBOT
#

Hey @vague gate!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes 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.
wide imp
#

and also the error you're getting

#

can you format it properly please?

vague jewel
#

!paste

subtle rockBOT
#
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.

vague gate
#
def another_letter(chosen_word):
       letter_counts = Counter(chosen_word)
       predicted_letters = []
       for letter, count in letter_counts.items():
          if count > 1:
            predicted_letters.extend([letter] * (count - 1))
            return predicted_letters

#

i cant use predicted_letters outside the function

vague jewel
#

When do you use/call that function?

wide imp
#

looks like you're not calling that function at all

vague gate
#

nowhere

#

do i need to?

vague jewel
#

If you don't call a function the code inside will never run

vague gate
#

i have another function that i dont call and it works properly

sly elk
#

that's doubtful

vague jewel
#

Looks like you called the choose_word function

wide imp
#

also you really shouldnt define functions within an if block

#

unless you really know what you're doing

vague jewel
#

Do you understand what a function is?

vague gate
#

ok im wrong now it works

#

thanks

#

im stupid

vague jewel
#

No worries

#

Also you aren't stupid, just new, right?

#

You learned how to make codeblocks in Discord faster than most people

#

Also you can close this with !close

vague gate
#

nah im using python first time since 8 months. and then i used it maybe 2 times

#

so

#

yeah]

#

im new

#

not to programming

#

but language

#

and im pretty tired

vague jewel
#

Python can be confusing sometimes

vague gate
#

its 1 am in my country

vague jewel
#

Oh wow

#

Maybe working on this after some sleep is a good idea

vague gate
#

yea

vague jewel
#

Yeah

#

Most people can't figure it out at all

remote birch
#

so many ppl just ignore any bot msgs

vague jewel
#

True

subtle rockBOT
#
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.