in Education by
This is my code that displays output that I would like to alter: import json from collections import OrderedDict with open('users.json', 'r') as file: data = json.load(file) ordered_data = OrderedDict(sorted(data.items(), key=lambda k: -k[1]['balance'])) first = ordered_data.popitem(last=False) print(first) Output: ('<@!702221444796383454>', {'balance': 90}) I wanted to code the output like this instead: 702221444796383454 90 I have tried the "".join() and I tried googling things to try and find a solution but I could not find anything. Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
After you get a variable first you can extract the bits of information you want into the string, and if a first part is always in that format you can splice it up. output =f"{first[0][3:-1]} {first[1]['balance']}" print(output) Improve your knowledge in data science from scratch using Data science online courses

Related questions

0 votes
    I used the pyhton: for m in regex.findall(r"\X", 'ल्लील्ली', regex.UNICODE): for i in m: print(i, i.encode(' ... कृ','प','या','ल्ली' Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have just built my first model using Keras and this is the output. It looks like the standard output you get ... - loss: 0.1928 Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I'm starting with input data like this df1 = pandas.DataFrame( { "Name" : ["Alice", "Bob", "Mallory", ... Any hints would be welcome. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I am trying to make an app that can get the patient's symptoms as inputs and outputs the three most likely ... classes[sortedshit[2]]) Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I had some Python 2 code as follows (pardon the indentation): def getZacksRating(symbol): c = httplib.HTTPSConnection("www. ... data.split(' ')[1] result = ratingPart.partition("...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    Should I learn R or Python for Data Science? Select the correct answer from above options...
asked Jan 17, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me how Python is better for Data Science compared to R? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    Suppose I have a Tensorflow tensor. How do I get the dimensions (shape) of the tensor as integer values? I ... 'Dimension' instead. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    While training a tensorflow seq2seq model I see the following messages : W tensorflow/core/common_runtime/gpu/pool_allocator ... GB GPU Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    While training a tensorflow seq2seq model I see the following messages : W tensorflow/core/common_runtime/gpu/pool_allocator ... GB GPU Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    Classification problems, such as logistic regression or multinomial logistic regression, optimize a cross-entropy loss. ... jungle. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I am training on 970 samples and validating on 243 samples. How big should batch size and number of epochs be ... on data input size? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I have the pandas data frame with a column designated to town names. After each town name, I am adding a word " ... .csv', index=False) Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have the function and want to create a new column df['growth_factor'] which will have a derived value in it. ... can I achieve this? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have a set of oil wells compiled in the panda's data frame. It looks like this: wells = pd.DataFrame({'date ... -01-01 FIELDZ 10.8 Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
...