Posts

Showing posts with the label savings

Best news I had so far today!

Image
 Hello, Here's a snipet that I found and modify to get input from user. Hope you like it. Please let me know if it is "pythonic" enough for you! Enjoy # SCRAPING TOOL TO GET RECIPIE SITES FROM THE INTERNET: # Documentation:  https://pypi.org/project/recipe-scrapers/ from recipe_scrapers import scrape_me # give the url as a string, it can be url from any site listed below scraper = scrape_me('https://www.allrecipes.com/recipe/158968/spinach-and-feta-turkey-burgers/') # Q: What if the recipe site I want to extract information from is not listed below? # A: You can give it a try with the wild_mode option! If there is Schema/Recipe available it will work just fine. scraper = scrape_me('https://www.feastingathome.com/tomato-risotto/', wild_mode=True) scraper.title() scraper.total_time() scraper.yields() scraper.ingredients() scraper.instructions() scraper.image() scraper.host() scraper.links() scraper.nutrients()  # if available scrape_dict = scraper.links() # ...
USEFUL PYTHON TIPS AND TRICKS 👀 I'd like to share this today!!!  # Swap two variables with one line of code. Shorten your code a = 1 b =2 a, b = b, a # Duplicate strings without looping fruit_names = "Banana", "Mango" print (fruit_names * 4) # Reverse a string my_words = "The Quick Brown Fox" reverse_words = my_words[::-1] print(reverse_words) # Compress a list of strings into one string my_words = ["This", "is", "a", "Test"] combine_all = " ".join(my_words) print(combine_all) # You can also compare or evaluate in a line of code x = 100 res = 0 < x < 1000 > 50 print(res) # Find the most frequest element in a list test_list = [4, 3, 2, 3, 2, 4, 3, 6, 9, 41, 2, 3, 4] most_frequent = max(set(test_list), key = test_list.count) print(most_frequent) # Unpack list to separate variables (or assign list to separate varabiels) arr_list = [1,2,3] a,b,c = arr_list print(a,b,c) # One-liner if-else statemen...