Files
ui-cviko1/notebook/cviko1_1.ipynb
2025-02-19 22:11:03 +01:00

5.9 KiB

In [9]:
text = "Some not interesting text input"
In [10]:
words = text.split(" ")
In [11]:
words
Out[11]:
['Some', 'not', 'interesting', 'text', 'input']
In [12]:
for word in words:
    print(word)
Some
not
interesting
text
input
In [13]:
"The lazy fox jumps over the lazy dog".split("the")
Out[13]:
['The lazy fox jumps over ', ' lazy dog']
In [14]:
len("Hello")
Out[14]:
5
In [15]:
len(words)
Out[15]:
5
In [16]:
len(words[0])
Out[16]:
4
In [18]:
"text" in words
Out[18]:
True
In [19]:
text.count("text")
Out[19]:
1
In [20]:
long_words = [word for word in words if len(word) > 4]
In [21]:
long_words
Out[21]:
['interesting', 'input']
In [22]:
"Hello".title()
Out[22]:
'Hello'
In [23]:
capitals = [word for word in words if word.istitle()]
In [24]:
capitals
Out[24]:
['Some']
In [25]:
"Adam".upper()
Out[25]:
'ADAM'
In [26]:
"Adam".lower()
Out[26]:
'adam'
In [31]:
text = "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s , when an unknown printer took a galley of type and scrambled it to make a type specimen book ."
In [33]:
len(set(text.split(" ")))
Out[33]:
30
In [ ]: