Pythonbeginners Ideas - Deepstash

pythonbeginners

4 ideas

TOP STASHERS

RELATED TOPICS

IDEAS ON THIS TOPIC

Learning Python: Inserting to a list plus clearing

In the image you can see i am starting with a list with three element, but if you look at the output its outputting 4, this is because i am using insert, when you use insert you need to define where you want the element to go and then the value to be placed in there, its a very simple concept to do and understand.

Next is count, this is as you would think, so in the () you enter a value that is in the list and it will output the count of all values, it wont add the elements, it just counts so you can see how many are there. Lastly we have clear which is self explanatory, it just clears the list

2

STASHED IN:

1

Continue learning about lists

🚶 On a walk

1 IDEA

0 Comments

Learning Python: Removing from a list

In todays image we can see that i am using two new keywords, remove and pop.

The best way to think about it is that pop "pop()" removes the last element from the list, or you could put a index value, so in this case in the image i have put 1, this is the second element because python starts with 0. Next we have remove and this wants to know the value you want to remove, so in this case i entered a string, and it removed it from the list.

If you was to put "name = user.remove("sam")" it would take out the value from the list and put into the variable to be used later. 

1

STASHED IN:

1

learning is the best this we can do to better our selves, teach each other

🚶 On a walk

1 IDEA

0 Comments

Learning Python: Adding to a list

So last time was about lists, and how to add elements to the list manually, but now lets look at adding a user but the user enters the info.

I have made a empty list, in this case i have done it very simply and asked the user and put that into a variable.

Once this is done then to add it to the list all we need to do is reference the list so in this case "user" and then followed by a full stop, from here you should see a list of different functions you could use, but in this case we are looking at the "Append". This will add the data in the variable to the list. print the list a have a look

STASHED IN:

1

Lesson 13/50, on the basics of python

🚶 On a walk

1 IDEA

0 Comments