Just a wee thought:

    if isinstance(dict(), typein):
>        newdict = {}
>        dl = instring.split()
>        if len(dl) % 2 != 0: raise Exception ("list entries must be
>even") # so they match
>        for idx in range(0,len(dl),2):
>            newdict[dl[idx]] = dl[idx+1]
>The for loop can be replaced with:

newdict = dict(zip(L[::2],L[1::2]))

Which avoids the explicit arithmetic and indexing and is therefore, arguably, 
cleaner... I'd probably wrap it in a try clause too:

if isinstance(dict(),typein):
   try: newdict = dict(zip(dl[::2],dl[1::2]))
   except TypeError:
    raise ValueError("input lists must be an even length")

And, since you always split the input, move that above all the isinstance() 
tests...

Similarly you don't need the loops for lists or sets, just use:

newlist = dl

and 

newset = set(dl)


But that doesn't answer your question about incrementing the globals! :-)
To me it looks from your sample data  like it is working!

Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to