TypeError: string indices must be integers, not 'str'…. accessing values in a dictionary

it works once but in the next line it will have the error in the title. Traceback (most recent call last): File "c:\Users\User\AppData\Local\tmc\vscode\mooc-programming-24\part07-15_who_cheated_2\src\who_cheated_2.py", line 51, in <module> print(final_points()) ^^^^^^^^^^^^^^ File "c:\Users\User\AppData\Local\tmc\vscode\mooc-programming-24\part07-15_who_cheated_2\src\who_cheated_2.py", line 29, in final_points print(maxs>wank[line[0]]) ~~~~^^^^^^^^^ TypeError: string indices must be integers, not ‘str’ # Write your solution here from datetime import timedelta,datetime import… Read More TypeError: string indices must be integers, not 'str'…. accessing values in a dictionary

Extract values from one array using the indices of maximum values of another array

I have two 2D arrays x and y. x = np.array([[2,4,6], [9,4,6], [6,8,3]]) y = np.array([[88,55,33], [43,87,65], [98,34,56]]) Using the argmax function, I found the indices of the maximum values of x along axis 1. idx = x.argmax(axis=1) output: array([2, 0, 1], dtype=int64) now, I want the the values from array y, which are on… Read More Extract values from one array using the indices of maximum values of another array

return all indices of first elements in a list where subsequent values increase incrementally

Need to find indices very similar to here But I have a list of multiple groups of incrementing values, e.g. lst = [0,1,2,7,8,9] Expected output: [0,3] >Solution : Version with a simple loop: lst = [0,1,2,7,8,9] prev = float(‘-inf’) out = [] for i,v in enumerate(lst): if v!=prev+1: out.append(i) prev = v out Same thing… Read More return all indices of first elements in a list where subsequent values increase incrementally

how to specify data on pearson correlation heatmap?

I have a pearson correlation heat map coded, but its showing data from my dataframe which i dont need. is there a way to specify which columns i’d like to include? thanks in advance sb.heatmap(df[‘POPDEN’, ‘RoadsArea’, ‘MedianIncome’, ‘MedianPrice’, ‘PropertyCount’, ‘AvPTAI2015’, ‘PTAL’].corr(), annot=True, fmt=’.2f’) ————————————————————————— TypeError Traceback (most recent call last) <ipython-input-54-832fc3c86e3e> in <module> —-> 1… Read More how to specify data on pearson correlation heatmap?

Parse over large JSON array of Objects from Facebook

This is the JSON array: { "id": "", "name": "", "posts": { "data": [ { "likes": { "data": [ ], "paging": { "cursors": { "before": "QVFIUnpFd2IwMlhuOWI3dJqelFNNEZAPWDlqeENTNkg1N2RqMm9zQXBreVV6bE9KNXJzX29LeXlMZAzhNT2x3TEhlcGk3OG1Bd3ZABRmpyTXhnNDZAWV2hR", "after": "QVFIUl9Vbm14cld0dm41OTFtKYmgtelBKall2bnBINjBQMXBiNkNCMUM0d21lQXptOXRvbklkU0pHbV9yejNBVG9Jb2hqQTFoem1mdm9zMnJn" }, "next": "" }, "summary": { "total_count": 84, "can_like": true, "has_liked": false } }, "comments": { "data": [ { "created_time": "2022-05-25T18:22:19+0000", "message": "", "id": "" }, {… Read More Parse over large JSON array of Objects from Facebook

Need to check all my variables for an ampersand, I put variables in a list and check using a for loop, but Python only changes value inside list

I’ve got the following code, but unfortunately it only changes the value inside the list. Is there any way I can change the value outside the list, so it can be used later in the script? street_number = "100 & 102" street_name = "Fake Street" suburb = "Faketown" allvariables = [street_number, street_name, suburb] ampersand =… Read More Need to check all my variables for an ampersand, I put variables in a list and check using a for loop, but Python only changes value inside list

How do I animate changes one at a time in SwiftUI on a button tap?

I have a loop where I update a value that changes the view. In this example I want the updates to happen one at a time so you see it ripple across the row, but they all happen at once. struct AnimationQuestion: View { @State var colors = "🟪🟨🟧🟦🟥🟫⬛️🟩⬜️".map { String($0) } @State var reversedColors… Read More How do I animate changes one at a time in SwiftUI on a button tap?

How to calculate sum of multiple responses inside a loop using javascript?

I have two loops as shown: for (var i = 0; i < nearPlacements.length; i++) { var meshInstances = nearPlacements[i].model.model.meshInstances; var mat; var matEach = 0; for (var i2 = 0; i2 < meshInstances.length; i2++) { mat = parseFloat(meshInstances[i2].mesh.indexBuffer[0].numIndices / 3); matEach += mat; } console.log(matEach); } console.log(matEach); outputs data as: How to display data… Read More How to calculate sum of multiple responses inside a loop using javascript?