Previous Lecture Complete and continue  

  Lesson 11: Lists of Things

Marek Ondrejka
goutham kumar
groceries = ['apple', 'banana', 4, 5, 'orange']

red = groceries[0]
yellow = groceries[1]
num = groceries[2]
num1 = groceries[3]
orange = groceries[4]

I love how Quazi shows us longer way first, then make it so easy showing us other methods for the same code!

data = 'Lumia 950 | 300€ | New'

details = data.split(' | ')
product = details [0]
price = details [1]
condition = details[2]

print('Product: ', product)
print('Price: ', price)
print('Condition: ', condition)
Brett Reppert
#Struggling to figure out how to do condition another way
data= ('PS3 | 250 | Used')
product=data [:data.index('|')]
price=data [data.find('|')+2:data.find('|', 7)]
condition= data [12:16]
print (product, price, condition)
Jackson AIken
data = 'XBOX 630 | 150 | New'
details = data.split('|')
product = details[0]
price = details[1]
condition = details[2]
Joseph Victor Swedlund
A code that separates song lyrics, and print them on their own line. (Raw code at the bottom)

#Intake: Paste any song lyrics into "Lyrics" below :)

Lyrics = '''

"Once I rose above the noise and confusion
Just to get a glimpse beyond the illusion
I was soaring ever higher, but I flew too high
Though my eyes could see I still was a blind man
Though my mind could think I still was a mad man
I hear the voices when I'm dreamin',
I can hear them say
Carry on my wayward son,
For there'll be peace when you are done
Lay your weary head to rest
Now don't you cry no more
Masquerading as a man with a reason
My charade is the event of the season
And if I claim to be a wise man, it surely
Means that I don't know
On a stormy sea of moving emotion
Tossed about I'm like a ship on the ocean
I set a course for winds of fortune, but
I hear the voices say
Carry on, you will always remember
Carry on, nothing equals the splendor
Now your life's no longer empty
Surely heaven waits for you
Carry on my wayward son,
For there'll be peace when you are done
Lay your weary head to rest
Now don't you cry no more


#Print Lyrics for testing "print(Lyrics)"

def Splitter(Thing_To_Split):

#Splitting "Lyrics" into a list
Newly_Split = Thing_To_Split.split(" ")

#To print new list for testing "print(Newly_Split)"

#Finding the number of words in the list, and naming that number.
Number_Of_Loops = len(Newly_Split)

#Loop a number of times = to the number of things in the list
for length in range(Number_Of_Loops):

#print lyrics word by word for as long as the loop goes


Raw code (except testing code)

Lyrics = ''' '''

def Splitter(Thing_To_Split):
Newly_Split = Thing_To_Split.split(" ")
Number_Of_Loops = len(Newly_Split)
for length in range(Number_Of_Loops):


Erlend Tryti Lindseth
Data = 'Xbox One | 200$ | New'

Split = Data.split('|')

Dhaval Bhimani
>>> data = "XBOX 360|150|NEW"
>>> product = data[:data.index("|")]
>>> price_n_condition = data[data.index("|")+1:]
>>> price = price_n_condition[:price_n_condition.index("|")]
>>> condition = price_n_condition[price_n_condition.index("|")+1:]
>>> product
'XBOX 360'
>>> price
>>> condition
Austin freestone
So I finished the circle of squares and then I went on to do my own thing. Here is the link if anyone wants to check it out. Also all feedback is welcome :D
Manu Maracuja
very nice, very clean code
poonam ahir
nice ..
Vincent Houckham
If we are only going to have 3 | in data. Can't we use this to find the price?:

data[data.find('|')+1:data.find('|', -data.find('|'))]
Théo Michel
Should we use Index or not ?

['timothy', 'bob', 'john']

Question: If it's the same with or without the 0(zero) why is it the different answer?
Austin Koons
unfortunately I believe that he made a verbal mistake by saying those would be the same thing. "race[0::-1]" is saying to start at 'john', don't go past 'timothy' and go backwards. If it starts at 'john' and goes backwards from there, there is no more elements to go to. however, if tweaked a little bit, it becomes more useful. Let's say instead "race[1::-1]" in this case, we are saying start at 'bob' and go backwards. This instance will return to us "['bob' , 'john']. As just another example, if we say "race[:0:-1] we are not specifying a starting index, but we are saying it must not include the first element and this will give us "['timothy' , 'bob']".I hope this helped and sorry about how late it was of a response, seeing as you did this unit 6 days ago, and I just got to it.
After some brainstorming I've come to the same conclusion :)
And for the answer...better late than never ;)
nagi reddy
data=" iphone / new / 500 "

details = data. split("/")

product = details[0]
condition = details[1]
prise = details[2]
prise1 = details[-1]
Moni AlFlahi
i asked Q on the last video , but nvm it u answered it here thnx anyways