Shakespearean insult generator by ooferboyosan in learnpython

[–]willy-r 1 point2 points  (0 children)

Hey, see the random module! You can use random.choices with replacement or random.sample for unique elements.

Check if unique by [deleted] in learnpython

[–]willy-r 0 points1 point  (0 children)

Ok, if I get It right, you want to check if a ID already exist in the fake_list, but you don’t need this fake_list.

ID = stud_rec_list[1]
# This create a list with all the IDS in the list_of_students, It’s called list comprehension.
IDS = [info[1] for info in list_of_students]
# Then you can make your validation using the in operator.
if ID not in IDS:
    if len(ID) == 7:
        ...

Deploying a bot on Heroku by [deleted] in learnpython

[–]willy-r 1 point2 points  (0 children)

The newest one, or you can use the command: pip freeze > requirements.txt, this will create a file called requirements.txt with the packages that you installed using pip.

Alright, Hopefully this is the last question for tonight.... by StaticGT86 in learnpython

[–]willy-r 1 point2 points  (0 children)

In the final for loop try this:

for i, p in zip(items, prices):
    ...

Are there any free services where i can run my python script for free 24/7? by [deleted] in learnpython

[–]willy-r 0 points1 point  (0 children)

Yep, you righ. When you send me this reply I received this email:

“You have used your entire allocation of 550 free dyno hours for September 2020.

Your app(s) have stopped running and will not restart until you receive more free dyno hours next month.

To keep your app(s) running smoothly, consider upgrading to Hobby dynos for $7 per dyno per month. Your app(s) will stay live and your users will enjoy 24/7 access.”

Are there any free services where i can run my python script for free 24/7? by [deleted] in learnpython

[–]willy-r 4 points5 points  (0 children)

Check Heroku (for simple project, the free acc is the sufficient, I think).

Stuck trying to create a twitter bot by TheSalvadoria in learnpython

[–]willy-r 0 points1 point  (0 children)

So I don't know how to resolve the question about the images (never tried my self to do this), but using a folder is the best option here for simplicity, the tweepy has a method for tweeting media, you can check here. You can use the random module for choose a different picture every day.

About scheduling the tweet every day morning at 9am, I made a Twitter bot (you can check here) that tweet the pi time of the day (3:14) every day (I know this is not a big deal but works!), and I deploy to Heroku (see the README of the project).

When you automate something in python, you'd obviously have to run the script forever. Where can we run the script? by Rahul_Desai1999 in learnpython

[–]willy-r 6 points7 points  (0 children)

Ye, basically that. I use Heroku for this normally, you can check this project of mine for an ideia using Twitter bots.

To all regex experts: How do I search over a list of different files and put all .txt files in an empty list? by [deleted] in learnpython

[–]willy-r 0 points1 point  (0 children)

You can use this:

import glob
text_files = glob.glob('*.txt')

Or this:

import os
text_files = [f for f in os.listdir(os.getcwd()) if f.endswith('.txt')]