Python List Organization!! #python #programming #coding

preview_player
Показать описание

Background Music:
Creative Commons / Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
Рекомендации по теме
Комментарии
Автор

Also, in case you want to swap two items by values:

a = inv.index('Gem')
b = inv.index('Sword')
i[b], i[a] = i[a], i[b]

MsWhiskey
Автор

indx = foo.index("a")
foo[indx], foo[-1] = foo[-1], foo[indx]

sabrysm
Автор

Ok I’m learning better than my class her. I love your clips. Do more

YouMe-mfed
Автор

That's why learning data structures and algorithms is very important 😂

Amankhan-cldq
Автор

Very cool! Sadly, this only works if you want to append to the END of the list, which was what the video was about, but there are easy fix-arounds to this! Awesome video nonetheless!

bloxymath
Автор

inv = ['gem', 'gem', 'gem']
print(inv.index('gem'))
>> 0

danilogsch
Автор

This is gonna be more useful for times when the list is bigger since most of time you know it's index anyways

maksiksq
Автор

Just wanted to add that it can be done as a oneliner

christian
Автор

len = len(inv)
indx = inv.index(‘gem’)

inv.insert(len-1, inv.pop(indx)
print(inv)

Rossilorenzo-yfoq
Автор

Also u can use slicing:
inv=inv[1:]+inv[:1]

AngryEgg
Автор

youtube i want these videos plz thank you algorithm

somethingmysterious
Автор

inv.remove("gem")
inv.append("gem")

joaogabrielsalvadorpaiva
Автор

Whhy not inv.remove("Gem") ?

SilverSuperGamer
Автор

a = [ 'gem', 'sword', 'health' ]
print(a)
pop = a.pop(0)
print(pop)
a.append(pop)
print(a)

is this good ?

mdyusufansari
Автор

but then you'd wrap that into a function that takes an argument of the item name, to give you a function that can move any item, right?

paultapping
Автор

How can i see colors of () in my pycharm please

hajeahajda
Автор

this is not practically applicable. Poor coding.

_Caose
Автор

don't mess with indices, when you haven't to

nurotn
Автор

Can you do a video or example video of pulling data or pattern matching from a file?

mcgriddletime
Автор

Bro, I need the theme you are using in this video.

mohammedelprince