How I created the code:
1.
I
created a variable for the unlucky number then used a count method based on how
many times the variable was in the list.
2.
I
checked to see if the count variable was less than or equal to zero, if it was
it would print “The number 5 is not in the list”
3.
If
the variable was found in the list, a second conditional statement would state
that the variable appeared and that its count would be deleted for however many
times it appeared. Ex) the number 5 will be deleted 4 times.
4.
Next,
a while loop was created in the second conditional statement that if the count of
the variable was greater than zero, it would remove the variable count by 1
until the variable was completely removed from the list.
No comments:
Post a Comment