Categories
Mastering Development

simple list comprehension question python

list=(1,2,3,4) for x in range(len(list)): print(list[x]) 1 2 3 4 but print(list) repeats the whole list 4 times ie 1,2,3,4 1,2,3,4 1,2,3,4 how does the x in the print(list[x]) cause only single numbers to come out? Like how could you put what the [x] is doing in english?

Categories
Mastering Development

Method should have signature error. ¿What can i do?

I want to update a health bar in the server and clients, because the health value is updated on server, but not the bar. I tried everything, but dont managed to fix it ERROR: AlRecibirDaño should have signature: public void AlRecibirDaño(System.Int32 oldValue, System.Int32 newValue) { } (at System.Void Health::AlRecibirDaño(System.Int32)) UnityEngine.Debug:LogError(Object) Mirror.Weaver.CompilationFinishedHook:HandleError(String) (at Assets/Mirror/Editor/Weaver/CompilationFinishedHook.cs:43) Mirror.Weaver.Log:Error(String) (at […]

Categories
Mastering Development

Problem with read and get batch with 2d array tfrecords dataset

I have some problems with reading Tfrecords file when get batch. First, this is my read_tfrecords.py file. import tensorflow as tf import os from glob import glob import numpy as np def serialize_example(batch, list1, list2): filename = “./train_set.tfrecords” writer = tf.io.TFRecordWriter(filename) for i in range(batch): feature = {} feature1 = np.load(list1[i]) feature2 = np.load(list2[i]) print(‘feature1 […]

Categories
Development

Return a list of paths to leaf-nodes from a nested list of lists

I have a dynamic tree structure that is represented as a list of lists – here is one such example, laid out with whitespace to illustrate the structure: [[‘first’, [0, ‘list1’], [1, ‘list2’], [2, ‘list3’]], [‘second’, [‘second_subda’, [0, ‘tup1’], [1, ‘tup2’]], [‘second_subdb’, [0, ‘tup3’], [1, ‘tup4’]]], [‘third’, [‘third_subda’, [0, ‘a’], [1, ‘b’], [2, ‘c’], [3, […]

Categories
Development

I have to find the maximum sum of 4 numbers from an array of 5. My code fails for bigger numbers

I had to find the maximum sum of 4 numbers from an array of 5, and a minimum sum in the same way. My code fails for some of the bigger test cases as the maxsum for some reason goes to negative #include<iostream> #include<vector> #include<algorithm> using namespace std; int minimini(int list[]){ int minisum=0; int taker; […]

Categories
Development Python

Python – how do I put a repeated process in a loop?

I have this list [‘5,4 4,5 8,7’, ‘6,3 3,2 9,6 4,3’, ‘7,6’, ‘9,8’, ‘5,5 7,8 6,5 6,4’] which contains 5 sublists. My goal is to add 1.0 to each number in the list. I think I need to change the format of the list to do this so I split the list into 5 individual […]