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

Syntax Error in Python

Hi! I've made this code: https://code.sololearn.com/c33RCD2f5H5X/#py I cannot make out the error.

13th Jul 2020, 2:02 AM
Shivank
Shivank - avatar
8 Answers
+ 1
You don't need to put global in python since when a variable is declared outside any python block it considers it global, global is a keyword that you can use inside functions when you want to modify the state of a global variable. problem solved. https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.geeksforgeeks.org/global-local-variables-python/amp/&ved=2ahUKEwjE-83sksnqAhVGMt8KHWZYAtsQFjADegQIAhAC&usg=AOvVaw3AzH98CtMNfFCuOU-Cvnur&ampcf=1
13th Jul 2020, 2:09 AM
Emanuel Maliaño
Emanuel Maliaño - avatar
0
So I should remove global from where?
13th Jul 2020, 2:12 AM
Shivank
Shivank - avatar
0
From everywhere where you don't need. I advise you to first see the use of global and then return to the code.
13th Jul 2020, 2:15 AM
Emanuel Maliaño
Emanuel Maliaño - avatar
0
I have removed the unrequired globals but a error is still coming.
13th Jul 2020, 2:24 AM
Shivank
Shivank - avatar
13th Jul 2020, 2:49 AM
Emanuel Maliaño
Emanuel Maliaño - avatar
0
It is not necessary to use multiple print to be able to a long paragraph instead you can use docstrings a like this in the code, something else is not necessary to use str (input ()) since input () returns a String and always give it format your code to look better.
13th Jul 2020, 2:53 AM
Emanuel Maliaño
Emanuel Maliaño - avatar
0
And as a last suggestion visit the link that I put you in previous messages so you will understand why the global keyword is within some functions, since you might think that it is the same as you had it but it is not. Happy Coding👌
13th Jul 2020, 2:56 AM
Emanuel Maliaño
Emanuel Maliaño - avatar
0
Thank you I made some minor changes and it is working well.
13th Jul 2020, 6:08 AM
Shivank
Shivank - avatar