Python 3 Programming Tutorial - List Manipulation

preview_player
Показать описание
In this Python 3 programming tutorial, we cover how to manipulate lists in Python. We are able to add things to lists by appending, we are able to remove them with del, we are able to order lists, reverse them, and more.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

incase anyone was wondering... if you put a * in front of the list it will leave out commas and quotes and brackets EX:

example == ["Hello ", "my ", "name ", "is ", "Lyndon"]
print(*example)

Output:
Hello my name is Lyndon

not ['Hello ', 'my ', 'name ', 'is ', 'Lyndon'] - which is what you would get without the *

lyndonrose
Автор

you explain this better than my python professor in college

FindAllHere
Автор

Be careful with x.remove(x[2]). It does not remove the 3rd element in the list, it removes the "first occurrence of the value of the 3rd element". So for your example if you do x.remove(x[4]), you will be removing the x[1] not x[4].


Other than that, good tutorial.

GokhanTurhanGoogle
Автор

In your example, if you print x.index(2) it will only give the first index. You can specify from where to start search (x.index(2, 3) means it will search for 2 from the 3 index) and where to end (x.index(2, 3, 7) will search for 2 between the 3rd and 7th indexes). And you can create a list of indexes of any object using a loop.

RealMcDudu
Автор

Sentdex has consistently been amonst my favourite 2 or 3 python YouTubers. Easy to follow and never too fast.

stuthomas
Автор

I never thought I'd see the day where Edward Snowden would be teaching me Python. Thanks, it really helped! :)

TobyTheUchiha
Автор

Hey Dark Code thanks for the suggestions! Once I am done with these basics, I plan to move into the vanilla modules. I'll cover those you mentioned for sure for Python 3.

sentdex
Автор

Watched this video on pythonprogramming.[net] I had to come over to Youtube to thank you. You answered my question in the 1st few minutes, how to manipulate each individual number in a list within a list within a list within a list within a list wit....

WisomofHal
Автор

Have enjoyed watching and learning from your videos. They are very informative and you are helping me as an ICT teacher to teach programming in school. Not easy when we only really covered ICT and a tiny bit of Visual Basic an University. Thank you for taking the time to make them.

tapdance
Автор

Thanks, man. I was wanting to ask this whiz at school, but then I saw this and I now kind of understand the simple commands around lists.

dalemackenzie
Автор

I'm a new student trying to learn, so I can become a programmer with python and I have a project on how to make a port scan.

So far I already make a port scan with Python3, and it scans fine, give a date and everything working good so far.

I see on your video tutorial you give example on how List Manipulation.

I would like to ask for your advice if you can and guide me on how I will add this 3
in a Python script, I have:

2. System should look for all the ports between the range of 1 to 1025
3. If the Ports is open, it should create a file and add an entry for port number
4. In case of any exception for instance “host is not available”, “host name could not be resolved” or
due to any other error, you need to write that exception into the same file.


Thank you and Merry Christmas.

rafy-ivanmorales
Автор

Great tutorial. One useful thing in Idle is the auto completion (which I just found out about). If you are using a class you can see what functions it has with Ctrl+space  . For example if you have a list called x.   If you type x the press Ctrl+space, it will tell you all the methods for the list that are available.

ChrisMcKennaCMK
Автор

To sort a list in descending order, you can include the optional parameter, reverse, which has a default value of False. Ex: lstName.sort(reverse=True) sorts the lstName list in descending order. Like someone else has commented, use sorted(lstName) if you don't want to mutate lstName. sorted() also accepts the reverse parameter as well. If you just want to display the list backwards, not sorting the values, use lstName.reverse().

On another aside, for index, you can have optional parameters specifying what range to search in a list which reduces the searching time. The general form is lstName.index(value, inc_start, exc_end) where value is the value/search key you are looking for, inc_start is the inclusive starting search position, and exc_start is the exclusive ending search position.

deirdreburke
Автор

You are the most wonderful person in planet earth, YOU saved my life, I was searching for a solution for my problem and I consumed the internet to find a solution, I almost give up then you saved my day, I love you

faisalaljurayyed
Автор

Great videos. Thank you. csv: comma separated values.

techied
Автор

new to Python and needed to get my head around list manipulation, fast .. your video was spot on for my needs - many thanks

tensor
Автор

You are a great teacher. Thanks so much for making these.

LukeAvedon
Автор

dude you are amazing im about to take finals and youre a lifesaver for my gpa thank you so

Grulz
Автор

I like your python tutorial video, your videos are the most clear I can find on Youtube.

beverlyHillsAgent
Автор

@sentdex let say you wanted to change the index location of the value "2" from 3 to 6. how would you go around doing that? or how would you go around changing the order of everything in the list?

allaboutpixhawkandrpi
visit shbcf.ru