Skip to main content

All Questions

Tagged with
3 votes
0 answers
55 views

Python: Iterating through 2 lists

I am trying to implement the following equation: Where zc is an equally spaced range of values e.g. t_array = np.arange(z_[0],z_[-1],0.01) In this case z_[0] = -15.336 z_[-1] = 15.336 I'm struggling ...
Justincomp's user avatar
-2 votes
2 answers
107 views

Python: best way to iterate through lists and store which has max value for each index

In Python (3.8), I have 15 lists of the same length. Each list contains floats. Here for the example, I will pretend I have 3 lists of length 5 to demonstrate my problem: List1 = [29.561801, 29.564141,...
Tritize's user avatar
  • 39
0 votes
0 answers
20 views

In python, iteration over specific condition with dataframe row not working

Help me in correcting the logic to attain the expected output. import pandas as pd # Sample DataFrame data = { 'phase': ['aaa', 'bbb', 'ccc', 'ddd', 'eee'], 'phase_input': ['NULL', 'io.flow,...
user12345's user avatar
  • 509
-1 votes
2 answers
39 views

Looping through string - Adding and skipping characters

I have the below code (which is wrong) and i would like to count the number of times the word "car" appears. So the output here would be 2. word="cccccccaaaaaaaaaaarrrrrccar" count=...
DMach's user avatar
  • 87
0 votes
0 answers
26 views

Operating XOR over a defined set of iterating matrices in python

I have a set of defined rules numbered [1, 2, 4, 8, 16, 32, 64, 128, 256]. Whenever I enter a positive integer, my code converts it into a binary representation of 9-bit. It then calls the rule ...
Masoom's user avatar
  • 15
0 votes
1 answer
79 views

How to auto populate the address in json

This is the json object I have [ { "person": "abc", "city": "united states", "facebooklink": "link", "united states&...
Tanu's user avatar
  • 1,462
1 vote
1 answer
46 views

How can I put the elements in the list next to the print out of the dictionary values?

DESIRED OUTPUT: Proportion of 1- letter words: 4.76% (1231 words) Proportion of 2- letter words: 16.14% (4177 words) Proportion of 3- letter words: 20.33% (5261 words) Proportion of 4- letter words: ...
Jordan Faulkner's user avatar
0 votes
1 answer
43 views

Merging 2 seperate list with different lengths without index

The 2 different list have 2 different lengths. so i would want to merge them based off the score. My example output is show below list1 = [ "ld Liked", "ld Disliked", "ld ...
Coding with noob's user avatar
0 votes
1 answer
81 views

How to restart iteration regardless of error in python [duplicate]

I have this code which produces a lot of errors which causes it to break out of the loop. These errors are due to coding issue in this code or because of remote server(s) issue. Is there anyway to ...
Slartibartfast's user avatar
0 votes
4 answers
153 views

Reversing dictionary key to value and vice-versa python

a_dict = {'one': 1, 'two': 2, 'thee': 3, 'four': 4} new_dict = {} for key, value in a_dict.items(): new_dict[value] = key print(new_dict) #result will be as below {1: 'one', 2: 'two', 3: 'thee', ...
Amanuel Yohannes's user avatar
1 vote
0 answers
100 views

Python script not working properly on excel file

My python code is not working properly on excel file. I wrote a python code to get an excel sheet, URLs from the sheet and extract the version number from URLs. Create a copy of the sheet with an ...
No One's user avatar
  • 23
2 votes
1 answer
117 views

How to make a list comprehension iterate a function

We want a list comprehension to iterate a function, for example this is what we want: list1 = [3, 1, 2] list2 = [f(f(f())), f(), f(f())] How would this be possible?
Brian Duong's user avatar
-1 votes
1 answer
53 views

For x in [list] does not iterate on each pass

Task: To find 2 values in a list which add up to make a target value. Problem: for x in sums doesnt seem to increment after each pass. class Solution: def twoSum(self, nums: List[int], target: int) -&...
ak231472's user avatar
2 votes
1 answer
86 views

How to pass coordinates from lists to multiple stepper motors at the same time, not in sequence?

I want to make multiple stepper motors turning at same time, with L298N driver. My idea is using relative coordinate on Milling machine, and separate x, y, z value from input coordinate before doing ...
Fayz Huang's user avatar
0 votes
2 answers
119 views

How to call class from another class in python

I am pretty new and trying to work on an algorithm challenge (Binary Inorder Traversal). I am trying to go through a tree (iterative) but for some reason there is a disconnect when I call the function....
Mike Curtis's user avatar

15 30 50 per page
1
2 3 4 5
31