#đź”’ My function not working
86 messages · Page 1 of 1 (latest)
@narrow pivot
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.
Like it tells me that it’s an ident error and when I fix it I get 3 new errors
Let me fetch the exact code in a second
str(input("This is an STR stop point press whatever characters on your keyboard and screen will clear "))
cls()
print("Hello this is a cool program")
def namelist(dagistan, khabib):
print("hi")
name_list = ["Johapp", "Matthew", "Sion"]
return dagistan,
#print(name_list, "\nHello guys")
Hey @narrow pivot!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
str(input("This is an STR stop point press whatever characters on your keyboard and screen will clear "))
cls()
print("Hello this is a cool program")
def namelist(dagistan, khabib):
print("hi")
name_list = ["Johapp", "Matthew", "Sion"]
return dagistan,
#print(name_list, "\nHello guys")
codeblock is done with backticks, not quotes
```
and py should be on the same line as the first 3 backticks
```py
<code here>
```
perfect
do you understand what indentation means?
What exactly do you want your function to do?
Yes, but what purpose does it have?
that's ok, that's why I'm asking, so I can see what you understand already
it's not just the first line that must be indented, it's any line that needs to be part of the function
def function():
print("This is in the function")
print("This is also in the function")
print("This too is in the function")
print("This is not in the function")
can you tell from this which lines are inside the function and which lines are not?
well based on the example I just showed you, is your return inside the function or outside the function?
ermm i dont see a return but from what u tell me its prolly everything except the bottom where it clearly states its not
lol
AHAAAAAAAAAAAAAAAAAAAAAAAAA
Tysm
hold on let me see if it works now
what exactly are you trying to do with your function though?
It doesn't really seem to be doing anything meaningful
i have a school project
for every class we need to create a python program
and this is one of the 8 instructions for ts program :
Create a program that accepts names and adds them to a list - use functions to add, remove and change names (NOTE! no print or input in functions)
this is like the third one
Your function is not doing what is asked
Yes, but you should not be creating the list inside the function
do you understand what the parameters of a function are for?
my native tongue isnt english could you rephrase that somehow?
def function(param1, param2):
when you define a function, you can also provide "parameters" inside the ()
these are "required information" for the function to do its job
no im not very informed over what they are for
okay
def get_rectangle_area(b, h):
return b * h
the parameters are b and h
you couldn't calculate the area with just b or just h, you need both
so this tells the function that when we need to use it, you must provide those 2 values
!e
def get_rectangle_area(b, h):
return b * h
print(get_rectangle_area(10, 5))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
50
when we use the function, it's known as "calling" the function
I gave it 2 values. 10 and 5
python is smart enough to know that 10 is b and 5 is h
yeah
ok, so instead, we could make a function that "adds something to a list"
instead of b and h
the parameters would be "the list we want to add something to" and "the thing we want to add to that list"
def add_to_list(a_list, value):
I'm really sorry but I have to go! Hopefully that's enough info to get started with!
np!
its appreciated
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.