Help with SyntaxError

Question:
I am learning Python
There is an exercise, the instruction given is : create a list called fruits including “pomme”, "banane"et “orange”
I write

fruits = ["pomme", "banane", "orange"]

I get this error message :

Repl link/Link to where the bug appears:

Screenshots, links, or other helpful context:

code snippet

I get this error message : File “main.py”, line 3
1. Créez une liste nommée fruits contenant les éléments "pomme", "banane" et "orange".
^^^^^
SyntaxError: invalid syntax

How should I write the list to have NO error message?

Hey, @boitardclaire welcome to the forums!

Can you please provide a link to the repl? This way it is easier for staff and members of the community to help you!

Also see this guide on how to share your code:

To create a string in Python, you need to put the text not in , but in " or ' (the key to the left of Enter).

Corrected code:

fruits = ["pomme", "banane", "orange"]

@boitardclaire
If your variable is called ‘I write fruits’, it won’t work as there cannot be spaces in the varuable name.
Instead, you can do I_write_fruits or IWriteFruits.
Hope this helps!

@boitardclaire remove where it says “Créez une liste nommée fruits contenant les éléments "pomme", "banane" et "orange".”

@NateDhaliwal she mean that op mistakenly included the instruction itself.

Instead of writing:

fruits = ["pomme", "banane", "orange"]

He must have included 1. Créez une liste nommée fruits contenant les éléments "pomme", "banane" et "orange". in his line of code too.

2 Likes

Well, it may be because of a specific platform or Python environment that you are currently using. One thing that I will recommend you to fix this error by checking you are running this code in a valid python environment such as Python IDE like Pycharm, Jupyter notebook or directly in a python script.
Thanks