Thread has been deleted
Last comment
Programmers come
United Kingdom clannad_2002 
Been struggling to make a function work in python for some days now. I am a novice at this but I can't find a solution online. Plz help before delete def main(score, min, max): if score > max: return max elif score < min: return min else: pass story = int(input("Story 1-5: ")) main(story, 1, 5) print(main) -> prints <function main at 0x018B9D18>
2021-02-26 13:40
Topics are hidden when running Sport mode.
In python
2021-02-26 13:41
1 reply
I only know cobra sry
2021-02-26 13:42
If(flag == brit) return no license
2021-02-26 13:41
vsm | 
Brazil Jordan21 better discuss on it
2021-02-26 13:42
5 replies
no, it's probably the worst place for trivial programming problems, those nerds make it big deal of it like it would full semester exam paper, instead of giving straightforward simple answer
2021-02-26 14:17
4 replies
2021-02-26 14:18
Brazil coldezra
I used to be like you but straightforward simple answers won't make you understand the problem and if it happen to happen again with another code structure you'll be lost once again having to search for easy answers that will only temporarily fix your problem, take 2 minutes to read and understand the code
2021-02-26 14:29
2 replies
depends where u at learning curve i guess, newbie won't understand complex answer either, so he does't need it, that would only discouraged him, and a simple answear allow him to move forward and progress his learning curve so he will be able understand more in the future
2021-02-26 19:44
1 reply
As the author of this thread I agree. In the very beginning sometimes all I need is to know the solution to a problem. When I know more, then I can learn and actually understand what is going wrong.
2021-02-26 19:54
ropz | 
Netherlands ONGix
Did you mean print(main(story, 1, 5)) ?
2021-02-26 13:44
2 replies
Thanks bro, this fixed it. Guess I have a lot to learn before I can make even a small weighted rating program haha
2021-02-26 13:45
1 reply
but you need to understand the difference between a function and a variable main is a function. it receives some data, do some shit, then throw up the result. the way you wrote, you didnt store the function result and your last line gave a syntax error, because print expected a result, not a function
2021-02-26 13:49
You shouldn't print main, that is your function, you likely want to print the result of main, so save that into a variable, and print that: result = main(story,1,5) print(result)
2021-02-26 13:44
6 replies
Never thought the day would come when an htlv admin helped me haha, thanks man.
2021-02-26 13:46
1 reply
you should have gone to stack overflow tho. but anyway here is a bit of insight. a function in python is an object and to get what it returns you need use parenthsis otherwise the thing 'main' in your code is nothing but a reference to that object. so if didn't use parenthsis by default you are getting the refernce value of that object.
2021-02-26 14:06
2021-02-26 14:02
also change the function name, bcoz main is the driver function in most programming languages
2021-02-26 14:11
how is hltv made ? looks like old scripts -> out dated to be honest and it's not that fast either so there is no compensation for "ugly" design will we ever see hltv in python?
2021-02-26 14:13
1 reply
2021-02-26 14:26
Singapore Am2de
That's memory address of your main function. You have to either write print (main(story, 1,5)) or first assign main function to variable. xyz = main(story,1,5) print(xyz)
2021-02-26 13:45
idk python but main is a function, print probably expects a string string = main(story, 1, 5) print(string) or somethign
2021-02-26 13:46
try | 
Brazil 1930
in javascript function result(score, min, max) { if (score < min) { console.log('unfortunately you failed') } else if (score >= min && score <=max) { console.log('well done') } else { console.log('invalid score') } }
2021-02-26 13:49
Norway AleXeiCS
I am learning Python as well, you just need to add values for the main function. print(main(X, X, X)) instead of just print(main) since you have defined parameters (score, min, max).
2021-02-26 13:51
def main(score, min=1, max=5): .... x = main(story) print(x) min and max are in-built python functions, u need to change them to something else if you get further issues handling them
2021-02-26 14:00
What happens if you pass to main(5,5,5) print that call in the console and tell me if it creates an empty line, I am interested.
2021-02-26 14:21
Login or register to add your comment to the discussion.