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.

  1. 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.”

  2. 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”

  3. Otherwise, it will print removing Y instances of the number X from the list

  4. I then created a while statement to remove the number assigned to unlucky from the luckyList using the remove method

  5. Finally, I printed the “updated  list” using the print function

Comments

Popular posts from this blog

GIS 5007 - About Me!

GIS 5100 Module 5 Damage Assessment

GIS 5100 M4