Eliminate "extra" variable

I

Igor Korot

Hi, ALL,
I have following code:

def MyFunc(self, originalData):
data = {}
dateStrs = []
for i in xrange(0, len(originalData)):
dateStr, freq, source = originalData
data[str(dateStr)] = {source: freq}
dateStrs.append(dateStr)
for i in xrange(0, len(dateStrs) - 1):
currDateStr = str(dateStrs)
nextDateStrs = str(dateStrs[i + 1])


It seems very strange that I need the dateStrs list just for the
purpose of looping thru the dictionary keys.
Can I get rid of the "dateStrs" variable?

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top