+ 1
"End" inside a loop
When using an "end" inside a loop to end a program, it works properly for Code Coach challenges, but it displays an error message if I try to do the same on Jupyter Notebooks. Why? Is there a better option than using the "end" inside a loop to achieve the expected result? Here is an example: string = input() chars_set = set() for char in string: if char in chars_set: print('Deja Vu') end else: chars_set.add(char) print('Unique')
9 Respostas
+ 6
If you want to end the whole program you can import sys.
Then you can use sys.exit() at the desired location.
The program will then end properly.
+ 4
end is not a Python keyword. Do you mean 'break'?
+ 3
"Break" would only end the loop, not the program.
+ 3
It worked! Thank you, Crash!
+ 3
Isabela Poley
My pleasure!
+ 2
Olá, Matheus Stefani. Esses dois cursos são visíveis apenas no aplicativo para smartphone. Não aparecem no site do SoloLearn.
+ 1
Muito obrigado!! Isabela Poley
0
Hi Isabela, it does not belong to this topic but I saw you mentioned some courses here, but I cannot find it.
Please, where I can find it?
"The new SoloLearn courses on "Data Science with Python" and "Machine Learning" are a great way to start!"
Thanks