The import OS
Def the clear () : OS. System (' CLS)
Import the random
Tre=[]
While True:
R=int (input (" in this type in the number of candidate: "))
S=r + 1
For t in range (1 s) :
Print (" first ", t, "a person is:")
N=input (' type here:)
Tre. Append (n)
Print (" currently has: ", STR (tre))
Tew=input (" are you sure you want to get started? (make sure/add/delete) :
")While tew=='delete' :
Shan=input (" please input you want to delete a (input \ \ "q" to cancel) : ")
If shan=='q:
Break
Elif shan in tre:
Del tre [shan]
Print (" currently has: ", STR (tre))
T=t - 1
The else:
Print (" there is no item!!!!!
")Ji=input (" you continue to delete (continue/terminate) : ")
If ji=='terminated' :
Break
Elif ji=='to continue' :
Print (" delete it!" )
The else:
Print (" wrong option!!!!!!
")Break
While tew=='increase' :
T=t + 1
Print (" first ", t, "a person is:")
Zeng=input (' in this type (input \ \ "q" to cancel) : ')
If zeng=='q:
T=t - 1
Break
The else:
Tre. Append (zeng)
Ji=input (" you want to continue to increase (continue/terminate) : ")
If ji=='terminated' :
Break
Elif ji=='to continue' :
Print (" continues to grow!" )
The else:
Print (" wrong option!!!!!!
")Break
Print (" currently has: ", STR (tre))
Print (" random screening...
")Feas=int (random. Randint (0, r))
String=tre (feas)
The import time
Tim=time. Strftime (' % % Y - m - H: % d % % m: % S ', time. The localtime (time. Time ()))
Print (" {} \ {} 000\000\000 - selected! \ n ". The format (Tim, string))
With the open (' xuanzhong. TXT ', 'a') as file:
File. Write (" {}, 00, 00, 00 {} \ 000 - selected!" . The format (Tim, string))
We=input (" if you want to exit or shutdown (yes/no/off the phone) : ")
If we=='is:
The exit ()
Elif we=='no' :
Clear ()
Tre=[]
Elif we=='shutdown' :
OS. The system (' shutdown - s - t 0 ')
The else:
Print (" wrong option!!!!!!
")Time. Sleep (1.5)
The exit ()
When running to del tre [shan]
Python report:
Traceback (the most recent call last) :
The File "C: \ Users \ \ Desktop \ TTTTT HP \ slot machines. Py", line 19, in & lt; module>
Del tre [shan]
TypeError: list indices must be integers or slices, not STR
Bosses genuflect is begged help
Online etc.!!!!!!!!!!
CodePudding user response:
Using tre. Remove [shan] del which position of the element is to remove the listCodePudding user response: