ua = UserAgent() word = [ua.ie, ua.opera, ua.chrome, ua.firefox, ua.safari, ua.msie, ua.google] if number isNone: user_agent_list = word return user_agent_list, random.choice(user_agent_list) elifint(number) > 0: numbers = [n for n inrange(int(number))] user_agent_list = [random.choice(word) for i in numbers] return user_agent_list, random.choice(word)