For Loops in Python to read Long URL from shortened URL -


i'm python beginner , struggling loop function. if run code receive long url last entry. ideas? thanks

import urllib2 beautifulsoup import beautifulsoup  x in ('civ8jguveh','isrohi98ag','taz38yubob'):   shorturl = 'http://t.co/' + str(x) output = urllib2.urlopen(shorturl)  print output.url 

you reassigning variable every time before opening or printing url. need indent code assigning , printing output variable done within loop:

import urllib2 beautifulsoup import beautifulsoup  x in ('civ8jguveh','isrohi98ag','taz38yubob'):   shorturl = 'http://t.co/' + str(x)   output = urllib2.urlopen(shorturl)    print output.url 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -