# Introduction To Lists In Python (Python Tutorial #4)

///Introduction To Lists In Python (Python Tutorial #4)

## Introduction To Lists In Python (Python Tutorial #4)

How to use Python lists.

This entire series in a playlist:
Support me on Patreon:

source

By |2019-07-03T20:21:12+00:00July 3rd, 2019|Python Video Tutorials|33 Comments

1. UpNorth July 3, 2019 at 8:21 pm - Reply

Hahaha .. dafuq is with what i have done. I tried it before he shows the solution and here is my program. This might seem funny but the output swapped the strings.

a = ["banana" , "apple" , "microsoft"]

a[2] = "banana"
a[0] = "microsoft

print(a)

'microsoft' , 'apple', 'banana'

print("xD")

2. Maaz July 3, 2019 at 8:21 pm - Reply

anyone knows how this code works
b[0],b[2]=b[2],b[0]

3. Crius Titan July 3, 2019 at 8:21 pm - Reply

b[0] = "microsoft"

b[2] = "banana"
print(b)

3 lines cuz i like it simple xD

4. Tommy Wit July 3, 2019 at 8:21 pm - Reply

I am having a problem following the code of the list swap shortcut. b(2) = b(2) . Amazing videos easy to follow the code.

5. Pramisha Shrestha July 3, 2019 at 8:21 pm - Reply

Why i cant use append function?

6. Hatul July 3, 2019 at 8:21 pm - Reply

Hi, CSDojo . I tend to think you are showing us one of the sorting types example like bubble sort and etc. Am I correct? Thank you.

7. A B July 3, 2019 at 8:21 pm - Reply

Is there another way to run the code without using the mouse to press run (when using Jupyter)? Thank you.

8. SpacialEthan July 3, 2019 at 8:21 pm - Reply

This is amazing i took the code to convert miles to km to make another converter, its a converter that tells you how old you will be when for eg. your mom is 50
The code is
def convert(Mom):
return Mom – the age (difference between your mom now)

then you say
print(convert(50))
My family were so amazed!
Tysm!

9. TN Legend July 3, 2019 at 8:21 pm - Reply

b = ['banana', 'apple', 'microsoft']

b.append(b[0])

b[0] = b[2]

b[2] = b[3]

b.pop()

print(b)

10. Anthony S July 3, 2019 at 8:21 pm - Reply

Every time I try to write a.append(1) to add to my list, there is a attribute error that pops up stating “the set object has no attribute ‘append’. Can anyone help explain What does this mean and how can I fix this issue ?

11. Jurassicing 64 July 3, 2019 at 8:21 pm - Reply

Hey when i do thr a.appent(1) line of code it gives me a attribute error
I don't know what im doing wrong

12. Vijayakumar V July 3, 2019 at 8:21 pm - Reply

Sir can u please tell the JavaScript

13. Ishaan Kulkarni July 3, 2019 at 8:21 pm - Reply

I ❤️ CS DOJO

(banana APPLE MICROSOFT) lol….

15. Deshpande Chandra Shekar Rao July 3, 2019 at 8:21 pm - Reply

Thank you Dojo, I liked your videos,very informative and useful to beginners like me.

16. Sam Hudd July 3, 2019 at 8:21 pm - Reply

hi YK, i am entering a.append(1) but i am getting an error ..attributeError: 'tuple' object has no attribute 'append' any idea what i am doing wrong?..many thanks.

17. Edward Lam July 3, 2019 at 8:21 pm - Reply

b=["banana","apple","microsoft"]
#swap item in index 0 with item in index 2

b.append(b[0])
b[0] = b[2]
b[2] = b[3]
b.pop()

18. Liliacfury Tail July 3, 2019 at 8:21 pm - Reply

I noticed you didn't explain how to add integers or strings to lists within a list. If anyone's curios, do the following:

a = [5, 10, 15, 20, [2, 4, 6,8]]
a[3].append(10)
print(a)

#Note that in the second line where is says "a[3]" the 3 is the index number of the list within a list. That means what's basically happening is the "a[3]" calls for that index item, which is the list that's within the original list, then appends the number "10" to it.

Hope I helped 🙂

19. Xuanyi Du July 3, 2019 at 8:21 pm - Reply

hi yk when I run the codes it always say "a" undefined, i'm using the newest python 3 version 2019, is it because of the version difference?

20. Timothy Hames July 3, 2019 at 8:21 pm - Reply

Excellent Training course for beginners!

21. Dragonfifthgaming July 3, 2019 at 8:21 pm - Reply

a.append(1) did not work

22. Arulkanthan Senthil July 3, 2019 at 8:21 pm - Reply

7:57 this also works
b[0],b[2] = b[2],b[0]edit: you mentioned this as well. 😅

23. TheDerpyParagon July 3, 2019 at 8:21 pm - Reply

8:00 why can't you just do this? b[0] = "microsoft"
b[2] = "banana"

24. Carlos. July 3, 2019 at 8:21 pm - Reply

Ur so fucken hot

25. Sayan Paul July 3, 2019 at 8:21 pm - Reply

c = ["Sayan", "Tarak", "Vishal", "Tanmoy"]

c[0], c[2], c[3] = c[2], c[3], c[0]

print(c)
# I use PyCharm for python coding
I intend to print c[0] at c[2], c[2] at c[3] and c[3] at c[0].
And the output is
['Vishal', 'Tarak', 'Tanmoy', 'Sayan']
where c[3] at c[0], c[3] at c[2] and c[1] at c[3].

26. Shivam Shivashish July 3, 2019 at 8:21 pm - Reply

Thank you very much sir.Your teaching methodology is incredible

27. Nobo July 3, 2019 at 8:21 pm - Reply

When i tried to a.append(x), it instead gives me attributeError: 'set' object has no attribute 'append'. Can someone explain to me what does that mean?

I'm really new in learning python and coding/programming in general, and this channel really helps a lot, thank you very much.

i did this : ['orange', 'ananas', 'monster']
a[0] = 'monster'

a[2] = 'orange'

print(a)
['monster', 'ananas', 'orange']

29. Jaycha July 3, 2019 at 8:21 pm - Reply

you can do this in a much dynamic way:
b=["banana" , "apple" , "microsoft"]
temp = b[0]
b[0] = b([len[b]-1])
b([len[b]-1]) = temp
print(b)

30. queiroz July 3, 2019 at 8:21 pm - Reply

i did this:
b.append("banana")
b[0] = "microsoft"
b.pop(2)
print(b)
[ 'microsoft, 'apple', 'banana' ]

31. Play 838 July 3, 2019 at 8:21 pm - Reply

I used () instead of square brackets [] and received and error when trying to add the a.append command woo wee this is no joke lol

32. Sarthak Puhan July 3, 2019 at 8:21 pm - Reply

Hi CS DOJO I am really influenced by u and also want to know Python so I have watched all your Python given videos . So can u tell me please that is this the end of the Python tutorial or u r going to post more after that creating a Twitter bot so if u can help me I will be great full. Thank you

33. Dakube July 3, 2019 at 8:21 pm - Reply

b[0] = "microsoft"
b[2] = "banana"
print (b)