users=['admin','tony','roger','lily']
if users:
    for user in users:
        users.remove(user)
print(users)
            Asked
            
        
        
            Active
            
        
            Viewed 40 times
        
    0
            
            
         
    
    
        Roger
        
- 1
- 
                    3One does not simply change list size while iterating over it – Yaroslav Surzhikov Jun 07 '18 at 07:41
- 
                    modiying a list **as you loop through the exact same list** is not a good idea unless you are 100% certain what you are doing – Ma0 Jun 07 '18 at 07:41
- 
                    1also why not just overwrite the original one with an empty one instead? `users = []` – Ma0 Jun 07 '18 at 07:42
- 
                    2If you just want to clear the list, use `users.clear()`. – timgeb Jun 07 '18 at 07:44
- 
                    @TaohidulIslam actually it work's as it should – Yaroslav Surzhikov Jun 07 '18 at 07:48
- 
                    Thank you for all of yours useful comments, because I am a self learning beginner and I am solving a little quiz on book. – Roger Jun 07 '18 at 08:28