Python Programming in Hindi

Please drop a mail to us at

What is the command to exit python and what command should I use when i want to stop executing my script?

I am not able to run a python script on my PC, the command prompt shows this error: “python is not recognized as an internal or external command"
Can someone help me with this?

There are many command that we can use to exit python, here are few of them:

  1. quit()
  2. exit()
  3. sys.exit()
  4. os._exit()

Let me briefly explain them:

The first three quit, exit and sys.exit are basically same and the reason that they both exist is to make it more convenient for programmers.Basically they raise SystemExit exception behind the scenes , which causes Python to stop. The first two are advised not be used in production code. This is because it only works if the site module is loaded. Instead, this function should only be used in the interpreter.But we can use sys.exit() as it is considered good to be used in production code for the sys module is always available.

os._exit exits the program without calling cleanup handlers, flushing stdio buffers, etc. Thus, it is not a standard way to exit and should only be used in special cases. The most common of these is in the child process(es) created by os.fork.

First make sure that python is already installed in your PC.If it is follow the steps below to resolve this error :

  1. Find a folder with the installed Python version as its name in C:\Program Files\Python38).Usually python is installed in C drive, in your case, if it is installed in any other drive,search that drive. If such a folder does not exist, download and install the latest version of Python here.
  2. Open this folder and copy its path.
  3. Right-click This PC, then go to Properties => Advanced system settings.Then click the Environment variables button at the bottom of this window.
  4. In the window that appears when a path variable exists, select it, ​and click Edit; otherwise, click New.
  5. In the next dialogue box, click on New and paste the previously copied path of the folder; then, click OK.
1 Like

Does python have arrays ? , if yes then please elaborate on python arrays vs lists.
Can some one explain me this.

What is Python error “SyntaxError: invalid syntax”?
Can some help me with this ?

A list is a data structure that’s built into Python and holds a collection of items and is mutable and ordered.The elements do not need to be unique and can be of different data types.

On the other hand,to use arrays in Python, you need to import either an array module or a NumPy package as it is not inbuilt in Python.Arrays are also lists which are ordered , mutable and can hold non-unique items but when it comes to types of items it can hold,there is a slight difference.The arrays you from with module can only be of the same type and you have to mention the datatypes beforehand, whereas NumPy arrays support different data types.Now lets us see some differences between array and list.

  • Since lists are built-in into Python we do not need to declare them beforehand whereas arrays need to be declared.
  • The lists are created by simply enclosing a sequence of elements into square brackets. Creating an array, on the other hand, requires a specific function from either the array module (i.e.array.array()) or NumPy package (i.e.numpy.array()). Because of this, lists are used more often than arrays.
  • Arrays can store data very compactly and are more efficient for storing large amounts of data.Also Arrays are much faster when it comes to mathematical operations.

An invalid syntax error means that there is a line that python doesn’t know what to do with.Python will attempt to highlight the offending line in your source code.

Please introduce a free certificate course on Java Script. Thank You

1 Like

Hi Javed,

Thank you for reaching out to us. We, at Great Learning Academy have launched over 80+ free courses with certifications on our website.
You can browse through all our courses here:
We are building more content videos for our learners to help them upskill. Meanwhile, stay tuned and keep checking the videos of your interest.

I am new in Python, i am getting this error “syntaxerror: invalid syntax” in my code and i can’t find the solution of my problem.Here is the code: ages = {‘barney’=82,}
SyntaxError: invalid syntax
Can somebody help me with this?

You have wrongly assigned the value to the key.You should use “ : ” instead of “=”.
ages = {‘barney’:82,}

Is there any shortcut to increment in python.I am using ++ as in use in C, but it is not working?

I am getting this error message in Python NameError: name ‘animal’ is not defined.Here is the code:
s = animal()
Class animal:
def out():
print(“Here is an animal”)

I have a trouble in PyCharm during running my script with Selenium WebDriver:from selenium import webdriver
ModuleNotFoundError: No module named ‘selenium’
I have checked that selenium was installed:

How to remove an element from a list in python ?

I am new at programming and started off with Python.I am getting this error “ indexerror: tuple index out of range ” and i can’t figure out why I am getting this error.




You are using tuple to store the items and index od tuples or any other such data type in python starts from zero.So there are two elements in your tuple,one at index 0 and other at index 1 and when you are trying to access index2, there is nothing there, so this raises an error.

You can use remove function() to remove an element that you specify in parentheses,here is an example

friends list

friends = [‘joey’, ‘monica’, ‘racheal’, ‘ross’,’chandler’,’phoebe’]

‘ross’ is removed