The following is my code:
data = raw_input("Please enter your particulars in the format of name/age/address ->")
pro = data.split("/")
name = pro.pop(0)
age = pro.pop(1)
address = pro.pop()
print name
print age
print address
I understand that the index of a list goes by 0, 1, 2 but when i pop the age (which should be index 1 in the list), it gives me the address when it is printed. Likewise for the address it gives me the age instead. Can someone tell me what in the world is wrong with this thing?
pop()is completely unnecessary...prolist shrinks afterpop(0), so in the next pop operation you only have 2 elements i.e age and address sopop(1)gives you address and like wise.name, age, address = data.split("/")and then you don't have to worry about indices at all.proafter eachpopoperation would have given you some idea of what was going on.