GIS 5103 Lab 2 - getting started in Python
For this week's exercise we were asked to use a string to create a list from which the last name could be extracted, we were asked to debug some code to generate a dice game and we were asked to create a random list of twenty numbers between 0 and ten and then create an if else while loop that would allow for the counting of the instance of the numbers
Assignment steps, Step 4: Create a loop that removes a chosen integer from the list previously generated
This step involves creating a while loop and the remove() method to remove the chosen integer from the previously created list. Give a detailed explanation of how you completed this step.
To start with, I created a variable, unlucky, and asked for user input: “Enter an unlucky number between 0 and 10 to remove from the list.”
Then I created an if-else statement where if the chosen unlucky number was not in the luckyList, it would print “The unlucky number X is not in the list”
Otherwise, it will print removing Y instances of the number X from the list
I then created a while statement to remove the number assigned to unlucky from the luckyList using the remove method
Finally, I printed the “updated list” using the print function
Comments
Post a Comment