def like_and_rt(self, method, dici, like, i):
    count = 0
    for tweet in tweepy.Cursor(method=method, **dici).items(i):
        self.pbar.update(1)
        count += 1
        try:
            if (like == True):
                self.api.create_favorite(tweet.id)
                sleep(1)
            tweet.retweet()
            string = ((('Retweeted: ' + str(tweet.id)) + ' @') + tweet.user.screen_name)
            tqdm.write(string)
            sleep(10)
        except tweepy.TweepError as error:
            if ((eval(error.reason)[0]['code'] != 139) and (eval(error.reason)[0]['code'] != 327)):
                tqdm.write((('\nError. ' + str(tweet.id)) + ' Retweet not successful. Reason: '))
                tqdm.write(((str(error.reason) + ' ') + str(datetime.now())))
                self.pbar.update((i - count))
        except StopIteration:
            break
def like_and_rt(self, method, dici, like, i):
    count = 0
    for tweet in tweepy.Cursor(method=method, **dici).items(i):
        self.pbar.update(1)
        count += 1
        try:
            if (like == True):
                self.api.create_favorite(tweet.id)
                sleep(1)
            tweet.retweet()
            string = ((('Retweeted: ' + str(tweet.id)) + ' @') + tweet.user.screen_name)
            tqdm.write(string)
            sleep(10)
        except tweepy.TweepError as error:
            if ((eval(error.reason)[0]['code'] != 139) and (eval(error.reason)[0]['code'] != 327)):
                tqdm.write((('\nError. ' + str(tweet.id)) + ' Retweet not successful. Reason: '))
                tqdm.write(((str(error.reason) + ' ') + str(datetime.now())))
                self.pbar.update((i - count))
        except StopIteration:
            break