Using the file module i have imported Check_product() from
Update_Stocks.py to Check_Customer.py, in Check_product() there is two condition are given, while it runs it reads the two conditions and displays in the output, whereas per condition it should read either one condition, but it fails, i have shared the output.
#๐ function code review
35 messages ยท Page 1 of 1 (latest)
@bleak dagger
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.
Closes after a period of inactivity, or when you send !close.
Can you share the code in a pastebin please?
pastebin?
!paste
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.
def check_product():
name = input("Enter the product name:").replace(" ", "")
for date, info in dates.items():
if name in info['product']:
print("The product is present")
else:
print("The product is not present")
# products()
Hey @bleak dagger!
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.
def check_product():
name = input("Enter the product name:").replace(" ", "")
for date, info in dates.items():
if name in info['product']:
print("The product is present")
else:
print("The product is not present")
# products()
why are you not using parameters?
And return statements?
how to it bro, can you suggest me
!return-gif
okay bro, here do i need to give name in parameter huh?
can you explain me bro on passing the data/info
!e
person = {
"name": "Bob",
"gender": "male",
"age": 24
}
def is_person_male(p):
if p["gender"] == "male":
return True
else:
return False
def is_person_over_18(p):
if p["age"] > 18:
return True
else:
return False
print(f"Is person {person["name"]} a male? {is_person_male(person)}")
print(f"Is person over 18? {is_person_over_18(person)}")
Here's a simple example @bleak dagger
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 19, in <module>
003 | print(f"Is person {person.name} a male? {is_person_male(person)}")
004 | ^^^^^^^^^^^
005 | AttributeError: 'dict' object has no attribute 'name'
okay bro, i will try it
!e
person = {
"name": "Bob",
"gender": "male",
"age": 24
}
def is_person_male(p):
if p["gender"] == "male":
return True
else:
return False
def is_person_over_18(p):
if p["age"] > 18:
return True
else:
return False
print(f"Is person {person["name"]} a male? {is_person_male(person)}")
print(f"Is person over 18? {is_person_over_18(person)}")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | Is person Bob a male? True
002 | Is person over 18? True
is there possible to alter my code and send it
With those 2 functions, I just pass in the variable p that I defined as a parameter in each. And then it returns whatever value I want back from those functions
bro, can you alter my function code and can you send me with crt syntax, next time i wiill keep it as reference bro
you need to learn how to do these things bro. Its basics
okay bro, i will try with the example bro, if errors occurs how can i contact you
just update here or open a new thread
okay bro
in parameter you have mentioned p is p refers to dict?
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.