Hello new to the forum and new to python,
my questions are:
- In step 3 of the below code why is 'members' recognized as a what i am guessing Boolean value, and if it is why is it considered to be 'True'
- In step 4 is the del function limited to deleting only one item from the list or was I doing something wrong? my original code was del Beatles[-1, -2]
The above code is supposedly correct although it took a little longer to figure out, I guess I learn best by making mistakes but I will stick to it
my questions are:
- In step 3 of the below code why is 'members' recognized as a what i am guessing Boolean value, and if it is why is it considered to be 'True'
- In step 4 is the del function limited to deleting only one item from the list or was I doing something wrong? my original code was del Beatles[-1, -2]
# step 1: Beatles = [] print("Step 1:", Beatles) # step 2: Beatles.append("John Lennon") Beatles.append("Paul McCartney") Beatles.append("George Harrison") print("Step 2:", Beatles) # step 3: for members in range(2): Beatles.append(input("New band member: ")) print("Step 3:", Beatles) # step 4: del Beatles[-1] del Beatles[-1] print("Step 4:", Beatles) # step 5: Beatles.insert(0, "Ringo Starr") print("Step 5:", Beatles) print("The Fab:",len(Beatles))I appreciate all of the help.
The above code is supposedly correct although it took a little longer to figure out, I guess I learn best by making mistakes but I will stick to it