Jimbo Mombasa
Jimbo Mombasa

Reputation: 528

Changing variables in a loop

I have a variable:

user = "jobrr"

And I want to loop the following but change what the variables represent after each loop cycle (so in the loop predefine what the variable for the coming loop will be)

example loop as long as y = true
    openurl = urllib.urlopen("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&contributor_details&include_rts=true&screen_name="+user+"&count=3600")
    user = user + "a" #just for example

how can I do this?

Upvotes: 0

Views: 191

Answers (2)

joaquin
joaquin

Reputation: 85693

user = 'username'
y = True

while y:
    openurl = urllib.urlopen("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&contributor_details&include_rts=true&screen_name="+user+"&count=3600")
    user = function_that_returns_user_name()

you only need to define function_that_returns_user_name()

Upvotes: 1

pycoder112358
pycoder112358

Reputation: 875

user = 'username'
y = True

while y:
    openurl = urllib.urlopen("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&contributor_details&include_rts=true&screen_name="+user+"&count=3600")
    user += "a"
    #You have to do something in here to change y or this will be an infinite loop

Upvotes: 6

Related Questions