Jun-07-2020, 06:24 AM
A few things:
1. Why do you redeclare
2. You've been told this in another thread, but if you want several items, you don't need to put them in a single string; you can use a list, tuple or set instead. If you are going to use a string, you don't need the parens on line 4.
3. You have several problems with the
- On line 2, you initialise it with an empty string. Why and not a 0? With the code as it is, you should be seeing an exception on line 7, because you can't add an int to a string.
- The variable is redeclared each time in the loop, so even if you had initialised it to 0, it would be reset to 0 each iteration, meaning that on every iteration it would be set to 1 on line 7 and so the expression
4. You really don't need line 3, since you're immediately overwriting the value of
5. Think about line 6 and the
1. Why do you redeclare
menu
each time in the loop? Surely you only need to declare it once outside?2. You've been told this in another thread, but if you want several items, you don't need to put them in a single string; you can use a list, tuple or set instead. If you are going to use a string, you don't need the parens on line 4.
3. You have several problems with the
tries
variable:- On line 2, you initialise it with an empty string. Why and not a 0? With the code as it is, you should be seeing an exception on line 7, because you can't add an int to a string.
- The variable is redeclared each time in the loop, so even if you had initialised it to 0, it would be reset to 0 each iteration, meaning that on every iteration it would be set to 1 on line 7 and so the expression
tries == 4
would never be true. Again, surely you want to declare it before the loop with its initial value.4. You really don't need line 3, since you're immediately overwriting the value of
add_menu
with the value you get from input
on line 5.5. Think about line 6 and the
menu
variable. Do you think that what you've written there is correct?