DEV Community

Yuri Reimers
Yuri Reimers

Posted on

Python fundamentals

For me, when I started my coding journey. I started with javascript for 6 weeks and then I started to learn python. Although, I felt more confident in my coding ability and learning how the computer reads code, I found it a bit tricky to learn the new syntaxes of Python. Below I have some examples of the basic of Python.

list: candy = ['Sour Patch', 'Skittles', 'Starburst']
tuple: candy = ('Sour Patch', 'Skittles', 'Starburst')
set: candy = {'Sour Patch', 'Skittles', 'Starburst'}

As you can see, my variable name is candy and I have shown you the different syntaxes between 3 data structures. Make sure that the names inside how '' or "". Making quotations will make sure that it is shown as a string so python can read the code.

Be sure to experiment in your python shell to test out the different data structures. You can use the type function to get comfortable with the different rules of each data_structure.

type(candy = ['Sour Patch', 'Skittles', 'Starburst'])

Top comments (0)