fruits = [
'apple',
'mango',
'pear',
'grapes'
]
prices = [
14,
7,
8,
25
]
max(fruits)
min(fruits)
max(prices)
max('hello world')
max(range(10))
x = list(range(10))
x
max(x)
sum(prices)
x,y,z = "abc"
x,y,z = (1,2)
"moshe cohen, 28, 1/1/1980, ussr, no"
name, age, *others = "moshe cohen, 28, 1/1/1980, ussr, no".split(',')
name
age
others
name, *everythingelse, address = "moshe cohen, 28, 1/1/1980, ussr, kremlin".split(',')
name
address
everythingelse
name, *everythingelse, address = "moshe cohen, 28, 1/1/1980, ussr, kremlin".split(',')
*blah, country, address = "moshe cohen, 28, 1/1/1980, ussr, kremlin".split(',')
blah
country
fruits
fruits += ['watermelon']
fruits
fruits = ['tomato'] + fruits
fruits
fruits.insert(3, 'banana')
fruits
fruits.pop(3)
fruits
fruits.remove('pear')
fruits
fruits.index('apple')
fruits.pop(fruits.index('apple'))
x = [1,1,1,1,2,2,2,1,1,1]
x.remove(1)
x
while 1 in x:
x.remove(1)
x
fruits = ['tomato', 'apple', 'mango', 'banana', 'pear', 'grapes', 'watermelon']
sorted(fruits)
sorted(fruits, key=len)
prices = [
10,
8,
5,
13,
20,
2,
17
]
d = dict(zip(fruits, prices))
d
d.get('apple')
d.get('grapes')
sorted(fruits, key=d.get)
sorted(fruits, key=d.get, reverse=True)
fruits.sort()
fruits
oops = """
Yeah yeah yeah yeah yeah
Yeah yeah yeah yeah yeah yeah
I think I did it again
I made you believe we're more than just friends
Oh baby
It might seem like a crush
But it doesn't mean that I'm serious
'Cause to lose all my senses
That is just so typically me
Oh baby, baby
Oops, I did it again
I played with your heart, got lost in the game
Oh baby, baby
Oops, you think I'm in love
That I'm sent from above
I'm not that innocent
You see my problem is this
I'm dreaming away
Wishing that heroes, they truly exist
I cry, watching the days
Can't you see I'm a fool in so many ways
But to lose all my senses
That is just so typically me
Oh baby, oh
Oops, I did it again
I played with your heart, got lost in the game
Oh baby, baby
Oops, you think I'm in love
That I'm sent from above
I'm not that innocent
Yeah yeah yeah yeah yeah yeah
Yeah yeah yeah yeah yeah yeah
"All aboard"
"Britney, before you go, there's something I want you to have"
"Oh, it's beautiful, but wait a minute, isn't this?"
"Yeah, yes it is"
"But I thought the old lady dropped it into the ocean in the end"
"Well baby, I went down and got it for you"
"Aww, you shouldn't have"
Oops, I did it again to your heart
Got lost in this game, oh baby
Oops, you think that I'm sent from above
I'm not that innocent
Oops, I did it again
I played with your heart, got lost in the game
Oh baby, baby
Oops, you think I'm in love
That I'm sent from above
I'm not that innocent
Oops, I did it again
I played with your heart, got lost in the game
Oh baby, baby
Oops, you think I'm in love
That I'm sent from above
I'm not that innocent
"""
oops2 = oops.translate(str.maketrans('', '', """!,"'`."""))
#print(oops2)
len(set(oops2.split()))
myfruits = d
myfruits
myfruits.keys()
for key in myfruits.keys():
print(key)
myfruits['apple']
for key in myfruits.keys():
print(key)
price = myfruits[key]
print(price)
myfruits.values()
myfruits.items()
for keyvalue in myfruits.items():
name = keyvalue[0]
price = keyvalue[1]
print(name, price)
for keyvalue in myfruits.items():
name, price = keyvalue
print(name, price)
for name, price in myfruits.items():
print(name, price)
oops2
import collections
words = collections.Counter(oops2.split())
sorted(words.items(), key=lambda x: x[1], reverse=True)