while / else

This commit is contained in:
Luiz Otávio
2022-10-28 08:25:20 -03:00
parent 05ec12b465
commit 69b7c76071

15
aula41.py Normal file
View File

@@ -0,0 +1,15 @@
""" while/else """
string = 'Valor qualquer'
i = 0
while i < len(string):
letra = string[i]
if letra == ' ':
break
print(letra)
i += 1
else:
print('Não encontrei um espaço na string.')
print('Fora do while.')