Python Programming in Hindi

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


You can use python -m pip install selenium in Python36 folder(or whatever version you are using at the time) and then try in PyCharm by selecting the corresponding interpreter in settings or else use PyCharm to do the installation by itself.

You need to define the class before you use it.Here is how :
Class animal:
def out():
print(“Here is an animal”)
s = animal()

Python does not support increment operators such as ++ or --.But here is a shorter way to achieve this.

For increamen use : x +=1

How to install Matplotlib?

To install the Matplotlib library, you need to open the Anaconda prompt.
Use the command : conda install matplotlib
Or if you want to install Matplotlib in the Anaconda environment then use this command
pip install matplotlib
Then import the package import matplotlib.pyplot as plt

the website you provide is not installing the anaconda now how can we download it