- 2
Which of the following codes are better ?
5 Respuestas
+ 2
Hi Sacar!
I would like to choose code #1.
In your second code, it breaks the loop when q entered and the rest will be ignored. So, it gives you 0 output if your first input is q so and on.
For example,
Input: 1 4 q 7 8
Output1: 20
Output2: 5
+ 1
I favor the second one because it gives the user the chance to quit…
But do notice that there is a syntax error in ‘if’ statement~ if x == ‘q’
+ 1
Sacar Very welcome~
+ 1
JUMP_LINK__&&__Python__&&__JUMP_LINK Learner
If user forget to enter q in the 2nd code, the code crashes so i think 1st one is better but people say nested try except is not a good choice( i don't know why they said that )
0
QWKKK oops thank you:)