WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-13-2009, 12:40 AM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
deleting elements inside a list problem

how can I remove all the elements inside a list?
Reply With Quote
  #2  
Old 02-13-2009, 12:48 AM
DrunkenBrit DrunkenBrit is offline
Member
 
Join Date: Dec 2008
Location: England
Posts: 25
If it's a simple python related question (and not specifically Vizard) you should try googling your questions first, 90% of the time you'll fine the answer

I Googled "Lists - Python" turned up:

http://www.faqs.org/docs/diveintopyt...lper_list.html

Scroll down the page and you'll fine your answer.

Last edited by DrunkenBrit; 02-13-2009 at 12:50 AM.
Reply With Quote
  #3  
Old 02-13-2009, 12:56 AM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
thanks, but i need to know how to remove all the elements with one code. For example I have a list:

list = [a,b,c,f,d,h,y]

and i want to write a code to delete from first element to last. I can't find any code.
Reply With Quote
  #4  
Old 02-13-2009, 01:16 AM
DrunkenBrit DrunkenBrit is offline
Member
 
Join Date: Dec 2008
Location: England
Posts: 25
I google searched again and came across this: http://effbot.org/zone/python-list.htm

It covers what you need to know If you're working with lists I suggest you read it.

To delete all elements in a list you use a slice like so:

Code:
list = [a,b,c,f,d,h,y]

del list[:] # Deletes all elements

print list # Check all items have been removed
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:43 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2002-2014 WorldViz LLC