Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. #In my list I have items stored in the format [ID, TITLE, NAME, DATE] and each column is separated using a ','. I use:
  2.     for item in my_list:
  3.         each_item_in_book = item.split(",")
  4.         item_id = each_item_in_book[0]
  5.         item_title = each_item_in_book[1]
  6.         item_name = each_item_in_book[2]
  7.         item_date = each_item_in_book[3]
  8.  
  9. #Sometimes my item will only have [ID, TITLE, NAME] (excludes date) and sometimes [ID, TITLE] (excludes name and date). When it's #like this, the code:
  10.     item_name = each_item_in_book[2]
  11.     item_date = each_item_in_book[3]
  12. #those two items wont be valid as they don't exist in the list. Is there a way to detect if those are empty?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement