check if “text” in variable something wrong. /u/cctl01 Python Education

I’m taking my first babysteps in python coding.

With the code below I’m using the function check to see if in the last hour a post is made in r/GameDeals and if the title contains the word ‘free’ or ‘0.00’ the information of that post is send to the send function which pushes a notification.

However the output below shows an entry where neither ‘0.00’ or ‘free’ is in the title. What am I missing?

def send(NAME,APPURL): conn = http.client.HTTPSConnection("api.pushover.net:443") conn.request("POST", "/1/messages.json", urllib.parse.urlencode({ "token": APP_TOKEN, "user": USER_KEY, "message": APPURL, "title": NAME, }), { "Content-type": "application/x-www-form-urlencoded" }) conn.getresponse() def check(): gratis=[] reddit = praw.Reddit( client_id=CLIENTID, client_secret=CLIENTSECRET, user_agent="linux:freeapp:0.1 (by u/cctl01)", ) print(reddit.read_only) current_time = time.time() one_hour_ago = current_time - 3600 #free game for submission in reddit.subreddit("GameDeals").new(limit=10): if submission.created_utc >= one_hour_ago: if 'free' or '0.00' in submission.title.lower(): gratis.append(submission) for grati in gratis: print("gamedeals "+grati.title) send(grati.title,grati.url) 

OUTPUT:

(venv) /home/python # python /home/python/notification.py True gamedeals [Fanatical] Winter Sale 2024 - Elden Ring (46% off), God of War Ragnarök (25% off), HELLDIVERS 2 (25% off) & more | Rotating flash deals, bonus game or coupon for spending $15USD/$21CAD/€15EU/£15GBP 

submitted by /u/cctl01
[link] [comments]

​r/learnpython I’m taking my first babysteps in python coding. With the code below I’m using the function check to see if in the last hour a post is made in r/GameDeals and if the title contains the word ‘free’ or ‘0.00’ the information of that post is send to the send function which pushes a notification. However the output below shows an entry where neither ‘0.00’ or ‘free’ is in the title. What am I missing? def send(NAME,APPURL): conn = http.client.HTTPSConnection(“api.pushover.net:443”) conn.request(“POST”, “/1/messages.json”, urllib.parse.urlencode({ “token”: APP_TOKEN, “user”: USER_KEY, “message”: APPURL, “title”: NAME, }), { “Content-type”: “application/x-www-form-urlencoded” }) conn.getresponse() def check(): gratis=[] reddit = praw.Reddit( client_id=CLIENTID, client_secret=CLIENTSECRET, user_agent=”linux:freeapp:0.1 (by u/cctl01)”, ) print(reddit.read_only) current_time = time.time() one_hour_ago = current_time – 3600 #free game for submission in reddit.subreddit(“GameDeals”).new(limit=10): if submission.created_utc >= one_hour_ago: if ‘free’ or ‘0.00’ in submission.title.lower(): gratis.append(submission) for grati in gratis: print(“gamedeals “+grati.title) send(grati.title,grati.url) OUTPUT: (venv) /home/python # python /home/python/notification.py True gamedeals [Fanatical] Winter Sale 2024 – Elden Ring (46% off), God of War Ragnarök (25% off), HELLDIVERS 2 (25% off) & more | Rotating flash deals, bonus game or coupon for spending $15USD/$21CAD/€15EU/£15GBP submitted by /u/cctl01 [link] [comments] 

I’m taking my first babysteps in python coding.

With the code below I’m using the function check to see if in the last hour a post is made in r/GameDeals and if the title contains the word ‘free’ or ‘0.00’ the information of that post is send to the send function which pushes a notification.

However the output below shows an entry where neither ‘0.00’ or ‘free’ is in the title. What am I missing?

def send(NAME,APPURL): conn = http.client.HTTPSConnection("api.pushover.net:443") conn.request("POST", "/1/messages.json", urllib.parse.urlencode({ "token": APP_TOKEN, "user": USER_KEY, "message": APPURL, "title": NAME, }), { "Content-type": "application/x-www-form-urlencoded" }) conn.getresponse() def check(): gratis=[] reddit = praw.Reddit( client_id=CLIENTID, client_secret=CLIENTSECRET, user_agent="linux:freeapp:0.1 (by u/cctl01)", ) print(reddit.read_only) current_time = time.time() one_hour_ago = current_time - 3600 #free game for submission in reddit.subreddit("GameDeals").new(limit=10): if submission.created_utc >= one_hour_ago: if 'free' or '0.00' in submission.title.lower(): gratis.append(submission) for grati in gratis: print("gamedeals "+grati.title) send(grati.title,grati.url) 

OUTPUT:

(venv) /home/python # python /home/python/notification.py True gamedeals [Fanatical] Winter Sale 2024 - Elden Ring (46% off), God of War Ragnarök (25% off), HELLDIVERS 2 (25% off) & more | Rotating flash deals, bonus game or coupon for spending $15USD/$21CAD/€15EU/£15GBP 

submitted by /u/cctl01
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *