#๐Ÿ”’ Inputs not working on vs code

39 messages ยท Page 1 of 1 (latest)

lime belfry
#

I have a bit of experience with python. I can write bare basic functions and use basic algorithms and stuff. I'm trying to make a function that requires input to work properly. Basically an npc would ask the player where their allegiance lies. I'm on vs studio code and every time I attempt to run it, it just spits out the prompt for the input and one of the answer choices with no input from me. I have the microsoft python extensions plus code runner. I'm kinda at a loss for what to do here.

muted vergeBOT
#

@lime belfry

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.

lime belfry
#

code goes as follows

orchid skiff
#

Save your code

#

And also, .lower is a method, you need to call it
Like your_answer.lower()

lime belfry
#

Thank you

#

Its still not allowing me to input anything

#

I just got an error message like NameError: your_answer is not defined when it's not even giving me the prompt for the input

arctic kite
#
your_answer = input("Who do you swear allegiance to?")
def ilthias_law():
    if your_answer.lower() == 'ilthias':
        print("Understood go forth")
    else:
        print("You are not welcome here, Begone!")
ilthias_law()````
#

you just needed round brackets

next knoll
#

that was mentioned already above

arctic kite
#

I know but thought I'd post the working code

next knoll
#

but the error they're showing doesn't appear to be from that code above, so it would be nice to see the latest from them

lime belfry
#

Hold on sorry I was taking care of getting some food

arctic kite
#

also I'd recomend avoiding the global scope with variables where possible so something like this ```py
def ilthias_law(your_answer):
if your_answer.lower() == 'ilthias':
print("Understood go forth")
else:
print("You are not welcome here, Begone!")

def main():
your_answer = input("Who do you swear allegiance to?")
ilthias_law(your_answer)

if name == "main":
main()
```

lime belfry
#

your_answer = input("Who do you swear your allegiance to?")
def ilthias_law():
if your_answer.lower() == "ilthias":
print("Understood, go forth")
else:
print("You are not welcome here, Begone!")
ilthias_law()

arctic kite
#

thanks bot

orchid skiff
#

!e

your_answer = "test"# input("Who do you swear your allegiance to?")
def ilthias_law():
    if your_answer.lower() == "ilthias":
        print("Understood, go forth")
    else:
        print("You are not welcome here, Begone!")
ilthias_law()
muted vergeBOT
lime belfry
orchid skiff
#

Did you properly save the file?

next knoll
lime belfry
next knoll
#

there are reasons to break this rule, but this is not a situation where you should

lime belfry
next knoll
#

or this is where we can introduce parameters, like Pixler's example shows

orchid skiff
lime belfry
next knoll
#

this little white dot means the file is unsaved

lime belfry
#

Alright, hold on I'm gonna just put the variable into the function itself

#

It worked

#

Thank you all

#

I anticipate that I'm probably gonna have more questions as I learn more python lol. But thank you all for your help

next knoll
#

Np, that's all part of the learning process ๐Ÿ™‚

muted vergeBOT
#
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.