Keith Bergreen

@Bergreen (10) • Indian Valley High School
import random
posted to Ask by minecraftmake55

If you only want to use the random library for certain sections of your code, then you should move that code into a separate python file, with the import random statement at the top.

For example, if you need to use the random library in your property class, you could make a new python file called Property.py, write import random at the top, and move your property class definition into that file.

Accidentally created an infinite loop cant find it
posted to Ask by OwenCastaneda

The problem is with this section of the code:

while choice != "0":
    print \
    ("""
    Critter Caretaker
      
    0 - Turn Off TV
    1 - Turn On TV
    2 - Channel Up
    3 - Channel Down
    4 - Turn Volume Up
    5 - Turn Volume Down
    6 - Info
    """)

choice = input("Choice: ")
print()

The program infinitely prints then menu while choice does not equal 0, but you are not updating choice within the while loop, so it ends up printing infinitely. Simply indent this line so it is in the while loop: choice = input("Choice: "). This will allow the variable to be changed each time the menu is printed.