[Solved] infinite while loop python

Your second while loop has no break point!!! Your first while loop runs until it detects motion and then enters the second loop, and your second loop runs forever. If you want both loops to work simultaneously then you should use threads!!! If not then make a break point in second loop. Simple example: import … Read more

[Solved] Why ‘IF’ made this code 2x faster as the output is the same and ‘IF’ make an extra check? [closed]

In words, the process you’re doing says “zero out the flags for all multiples of this number.” The if statement says “do the next step only if the current number is a prime.” The second sieve has to zero out all multiples of 2, then 3, then 4, … for every number in the sieve. … Read more

[Solved] scraping with selenium web driver

You should fix your XPath expressions. Use findElement for the first 3. findElements for the last. To get the home odd : //td[a[.=”bet365″]]/following-sibling::td[span][1]/span To get the draw odd : //td[a[.=”bet365″]]/following-sibling::td[span][2]/span To get the away odd : //td[a[.=”bet365″]]/following-sibling::td[span][3]/span To get them all : //td[a[.=”bet365″]]/following-sibling::td[span]/span Getting them all is probably better since you call driver.find_elements_by_xpath 1 time. … Read more

[Solved] Answer Error, Only outputting Zero

How to debug your (small) program Okay so let’s start from the top and go line-by-line. There’s a lot of issues here. aLimit=300 bLimit=500 cLimit=100 aPrice=20 bPrice=15 cPrice=10 ticketSold=1 totalIncome=0 These are all globals since you defined them in the module scope. That’s a Bad Thing. Don’t do it. If they’re constants, use CAPS to … Read more

[Solved] Python FOR Loop [closed]

Python alternative for your function def test(): for i in range(1, 10): print(i) Note out that python has no variable declaration as it is not strongly-typed language. Also instead of next it has indentation as depth of execution. solved Python FOR Loop [closed]

[Solved] Append not working like expected [closed]

You repeatedly append the same Mutation, and end up with multiple references to it in the list. If you want different Mutations, you have to make new ones. (I assume that’s what you think is the “problem”, as you never explicitly say what is wrong about the output.) 2 solved Append not working like expected … Read more

[Solved] Python class information from variable

Yes. Both animal and giraffe are references to the same underlying object. Very much like “Jala015” and “Jala Smith” and “mom” (or dad?) might all be references to the same person. Similarly, if you change the continent of the object via one of the references, that change will be visible through the other reference, since … Read more

[Solved] What is wrong with this code? I cant figure it out

days_of_week = [‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’] You forget the , after the ‘Thursday’, that’s why it will out of range. your code: def main(): # Variables total_sales = 0.0 # Initialize lists daily_sales = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = [‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’] for i … Read more

[Solved] I need help Funtion sort a-z condition [closed]

Hope you got the logic from my code below, if you have any questions, please ask them 😀 name1 = input(“Name 1 : “) name2 = input(“Name 2 : “) choose = input(“Select first or last : “) if choose == “first”: if name1 < name2: # check if name1 is in front of name2 … Read more

[Solved] Whats wrong with my JSON Object [closed]

Youre missing a closing ] at the bottom, this will work { “results”: [ { “text”: “@twitterapi http://tinyurl.com/ctrefg”, “to_user_id”: 396524, “to_user”: “TwitterAPI”, “from_user”: “jkoum”, “metadata”: { “result_type”: “popular”, “recent_retweets”: 109 }, “id”: 1478555574, “from_user_id”: 1833773, “iso_language_code”: “nl”, “since_id”: 0, “max_id”: 1480307926, “refresh_url”: “?since_id=1480307926&amp;q=%40twitterapi”, “results_per_page”: 15, “next_page”: “?page=2&amp;max_id=1480307926&amp;q=%40twitterapi”, “completed_in”: 0.031704, “page”: 1, “query”: “%40twitterapi” } ] … Read more

[Solved] python program to store a specific string from a file and store it in a variable

First off In your example json file you have inconsistent use of quotation marks, chose ‘ or ” and stick to it. Code import json data = json.load(open(“file.json”)) # this is the variable you are after variable = data[“my_id”] solved python program to store a specific string from a file and store it in a … Read more