Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!ra.nrl.navy.mil!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Re: Dictionary error Date: Tue, 25 Nov 2014 16:36:05 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 39 Message-ID: References: NNTP-Posting-Host: panix1.panix.com X-Trace: reader1.panix.com 1416933365 21265 166.84.1.1 (25 Nov 2014 16:36:05 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Tue, 25 Nov 2014 16:36:05 +0000 (UTC) User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:81520 In Thuruv V writes: > Please Clarify the 'TypeError: zip argument #1 must support iteration' > import openpyxl > book = openpyxl.load_workbook('c:/users/c_thv/desktop/tax.xlsx') > sheet = book.get_sheet_by_name('Thilip') > cell = sheet.cell(row=2,column = 4) > i = 2 > x = [] > y = []while i < 10: > keys = sheet.cell(row=i,column = 4) > values = sheet.cell(row = i,column = 5) > x.append(keys.value) > y.append(values.value) > i +=1 > mydict = dict(zip(keys,values)print mydict The purpose of zip() is to accept two (or more) sequences and return a single sequence with the corresponding members of the input sequences paired together. For example, if you had a list of names and a list of ages, calling zip on the two lists would produce single list of (name, age) pairs. But you're calling zip on two single items, not sequences, and you can't do that. Glancing over the code it appears that you're saving the cell contents in two lists, x and y. Perhaps you meant to call zip on those lists instead of on keys and values? -- John Gordon Imagine what it must be like for a real medical doctor to gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.