Functions in python code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Functions in python code

https://code.sololearn.com/c59pJNfW4Lv0/?ref=app In that code I’m trying to call functions so that it enables a user to insert a command when it prompts for a command. The calling functions part is what is getting me messed up here. Help me with my code.

21st Apr 2019, 3:45 AM
Safina Nganga
Safina Nganga - avatar
6 Answers
+ 1
The code structure seems to be wrong. command=int(input("Enter command:")) belongs in main() if command == RETURN_BOOK, the function return_book(books) needs to be called. return_book() needs a parameter "books" so you need to ask which book is returned before you can call the function return returned_book doesn't seem to make sense (but it's not necessarily wrong) => same for all other functions
21st Apr 2019, 4:46 AM
Anna
Anna - avatar
0
so how would it look like?
21st Apr 2019, 4:49 AM
Safina Nganga
Safina Nganga - avatar
0
i called it at the bottom but doesnt seem right to me cause it calls them order which is not what i want.
21st Apr 2019, 4:56 AM
Safina Nganga
Safina Nganga - avatar
0
they should call the functions randomly depending what the user types as a command
21st Apr 2019, 4:57 AM
Safina Nganga
Safina Nganga - avatar
0
well the code is suppose to be divided into 8 functions
21st Apr 2019, 5:15 AM
Safina Nganga
Safina Nganga - avatar