-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.py
41 lines (31 loc) · 845 Bytes
/
string.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'aula sobre strings'
nome = 'fredeus'
print(nome)
print(type(nome))
nome = "ginas's bar"
print(nome)
print(type(nome))
nome = 'angelina /n jolie'
print(nome)
print(type(nome))
### aspas duplas triplas serve como o /n também
### conforme o exemplo abaixo.
### utilizar \ permite o uso de strings como " '"
nome = """Angelina
JOlie"""
print(nome)
print(type(nome))
#aumenta tudo pra maiusculo
print(nome.upper())
#aumenta tudo pra minusculo
print(nome.lower())
#separa uma palavra a cada espaço, criando uma lista
# transforma em uma lista de strigns
print(nome.split())
#printa o que está de 0 até 3, ou seja "geek"
print(nome[0:4]) #operacao chamada de slice de string
#inverte a string no seu total, começa do primeiro
# ao último e DEPOIS inverte ela.
print(nome[::-1])
#metodo pra trocar letras
print(nome.replace('G', 'P'))