[Solved] Sort highest to lowest without built in [closed]

[ad_1] I dunno why one would do it without built-in functions, but here’s a working bubble sort example. http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort#Python def bubble_sort(seq): “””Inefficiently sort the mutable sequence (list) in place. seq MUST BE A MUTABLE SEQUENCE. As with list.sort() and random.shuffle this does NOT return “”” changed = True while changed: changed = False for i … Read more

[Solved] What’s the difference between ‘==’ and ‘in’ in if conditional statements?

[ad_1] The first statement if keyword.lower() in normalized: is checking if keyword.lower() string is one of the elements inside the list normalized. This is True. The other statement if keyword.lower() == normalized: is checking if keyword.lower() string has same value as normalized list. This is False. 1 [ad_2] solved What’s the difference between ‘==’ and … Read more

[Solved] Lists in Python 2.7 (compatible with 3.x)

[ad_1] You need a little more debugging here. For instance, check that your split gives you what you want. Second, please read https://stackoverflow.com/help/mcve — this lists our expectations for posting. Giving the actual input and error message would have given you an answer much sooner: you fed a list to fnmatch, which expects a string. … Read more

[Solved] one self for class in class

[ad_1] You only defined classes inside the namespace of class User. An instance of User don’t have magically instances of the inner classes (i.e. in Python there is nothing like a inner class). So class definitions inside other classes in normally not useful. You have to give the other classes an explicit reference to your … Read more

[Solved] Test for answers in an IF block [duplicate]

[ad_1] Write response = input(‘Would like to …?’).lower() if response == ‘y’ or response == ‘yes’: … Or if response in [‘y’, ‘yes’]: … Note that it’s not necessary to call str — your object is already a string. [ad_2] solved Test for answers in an IF block [duplicate]

[Solved] how to import .txt with space in filename

[ad_1] Wrap the file name in quotation marks like this “your file.txt” If you have a filepath, use the raw string (and backslashes in the copied filepath) by placing a r before the quotation marks: r”C:\Folder\Subfolder\another_one\your_file.txt” [ad_2] solved how to import .txt with space in filename

[Solved] How to use google-api-client for Google Cloud Logging

[ad_1] This is less easy to find because many of Google’s Cloud (!) services now prefer Cloud Client libraries. However… import google.auth from googleapiclient import discovery credentials, project = google.auth.default() service = discovery.build(“logging”, “v2”, credentials=credentials) Auth: https://pypi.org/project/google-auth/ Now, this uses Google Application Default credentials and I recommend you create a service account, generate a key … Read more

[Solved] Why sorting mixed list does not work [closed]

[ad_1] The problem is in your original data: >>> [-131.23, 33213, 4454, 566, -33, 465. -377.312, 5.6656] [-131.23, 33213, 4454, 566, -33, 87.68799999999999, 5.6656] because you forgot the comma and this does the substraction: >>> 465. -377.312 87.68799999999999 Just add the comma: >>> sorted([-131.23, 33213, 4454, 566, -33, 465, -377.312, 5.6656]) [-377.312, -131.23, -33, 5.6656, … Read more