[Solved] Ascending order , in list [duplicate]
numbers = sorted(numbers) If you want descending order: numbers = sorted(numbers, reverse=True) 0 solved Ascending order , in list [duplicate]
numbers = sorted(numbers) If you want descending order: numbers = sorted(numbers, reverse=True) 0 solved Ascending order , in list [duplicate]
just add strip to remove unwanted space/newline characters import sys print(“enter your password”) pword = (sys.stdin.readline()) if pword.strip() == “hi”: print(“i rule”) else: print(“sucker”) 0 solved python if variable == string wont work when you enter correct value [closed]
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
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
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
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
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]
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
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
num is an integer, and list() expects an iterable, hence the error. Did you want to obtain a list of integers representing the digits of num? If so you can try using map(): l = map(int, string) solved TypeError: ‘int’ object is not iterable; Python 2.7
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
that’s is because your eat function print to the stdout and does not return a string. you need to change your eat function to be: def eat(self): return “eats well” 1 solved How can I use the info from the parent class in a child object? [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
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&q=%40twitterapi”, “results_per_page”: 15, “next_page”: “?page=2&max_id=1480307926&q=%40twitterapi”, “completed_in”: 0.031704, “page”: 1, “query”: “%40twitterapi” } ] … Read more
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