while loop
Repeat the indented lines for as long as the condition is true.
while True:
passr = 10
while r < 60:
circle(r)
r = r + 15
Deeper Python in the console · In any playground, open Reference to copy these.
Repeat the indented lines for as long as the condition is true.
while True:
passr = 10
while r < 60:
circle(r)
r = r + 15
Leave the loop straight away; the program carries on after it.
breakThe value stored under that key. The key goes in quotes. Assign to it to change it: star["speed"] = 8.
star["speed"]Join a list of texts into one, with the text in quotes between each: "lamp, key".
", ".join(bag)Take an item out of a list. It stops with a ValueError if the item is not there, so check with in first.
bag.remove("lamp")A menu that keeps showing until a break runs.
while True:
choice = input("1 add, 2 quit: ")
if choice == "1":
pass
elif choice == "2":
break
else:
print("Please choose 1 or 2.")Keep many values in order under one name. The first item is place 0.
colours = ["red", "blue", "green"]Values stored under names (keys). One dictionary can hold everything about one thing.
star = {"speed": 5, "points": 1}True if the item is in the list (or the key is in the dictionary, or the letters are in the text).
if item in bag:
pass