All Questions

Tagged with
298 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5votes
1answer
349views

Alternate way to do Iterative name/variables in Pythonic while loop

So I know that it is a kind of pythonic heresy to modify a variable name while iterating over it but I have been searching for a good pythonic way to do this and can figure it out. In statistical ...
user avatar
  • 1,936
4votes
1answer
4kviews

Undefined variable $loop in Laravel Blade loop

according to the latest laravel blade documentation (https://laravel.com/docs/5.3/blade see "loops") I can "[...] use the loop variable to gain valuable information about the loop[...]". My laravel ...
user avatar
  • 121
2votes
4answers
45views

calculate the content of a variable

I'm learning python, and I have encountered a problem. for i in input: operator = i.split()[0] number1 = i.split()[1] number2 = i.split()[2] equation = (number1 + ' ' + operator + ' ' ...
user avatar
  • 21
2votes
1answer
112views

how Python for loop variable(K) in range(1,11) is used in a word like HHkC and show HH1C,HH2C......HH10C?

I ran a for loop for range(1,11) and used k as a variable. but K in HHk_C.txt or HHkC is not interpreted as HH1_C.txt or HH1C rather python read this as HHk_C.txt and HHkC. how can I tell python to ...
user avatar
2votes
1answer
44views

How do I assign a variable to an established loop of two lists in Python?

I have the following for loop assigned to a set of two list indices in Python, and must set it to the variable "names_and_ranks". How would I do that from here? for index in [0,1,2,3,4,5,6,7,8,9,10,...
user avatar
  • 19
2votes
2answers
73views

How can I include a variable in a vector in R?

In a loop, I want to insert "i" into a vector. How can I do that? I tried the following code: m1nash.best.response.coordinates<- NULL for (i in 1:2) { if(m1nash[1,i]>m1nash[2,i]) { ...
user avatar
2votes
2answers
613views

(BASH) Passing a loop variable into command that will be stored in a variable

I am trying to iterate through a line-by-line list of file ID strings (testIDs.txt) and pass them to an AWS command. The command should utilize the loop variable, and the output of the command should ...
user avatar
2votes
1answer
2kviews

Django Template loop with variable

I am having issue with django html variable so I made the below code which is working . {%for field in instance %} <tr> <td width="250"> {{ field.Item }} </td> <td> <input ...
user avatar
  • 256
2votes
0answers
262views

jinja2 for loop dynamic variable

I am trying to use a jinja2 for loop with an array variable whose name is dynamic. The template is london: stations: - station: name: waterloo - station: name: paddington paris: ...
user avatar
2votes
2answers
2kviews

Angular - ngFor change variable after click

So, lets assume i have this ngFor loop: <ng-container*ngFor="let rate of [1,2,3,4,5]"> <div (click)="change()">{{myVariable}}</div> </ng-container> I have variable 5 ...
user avatar
2votes
1answer
434views

define variable labels in a loop for existing variables SPSS

I have some variables V1 V2 V3 which I want to give variable labels in a Loop: variable labels V1 "Person 1". variable labels V2 "Person 2". ... Should be an easy thing, but as far as I could see ...
user avatar
2votes
3answers
1kviews

How to iterate/loop through multiple numbered variables in R

So, I'm new to programming in R, so I don't even know if this is feasible to even do. I have 50 matrices (50,000 rows by 10 columns) I'm trying to populate for a Monte Carlo simulation. I created all ...
user avatar
2votes
1answer
87views

Can someone tell me how to replace the following javascript code with a loop?

dataBase[0].valueline = d3.svg.line() .x(function(d) { return x(d["Date"]); }) .y(function(d) { return y(d[dataBase[0].columnline]); }); dataBase[1].valueline = d3.svg.line() .x(function(d) { return ...
user avatar
2votes
2answers
989views

Looping and if statements in SPSS

I'm new to SPSS and I'm a bit stuck on a problem. I have about 200 variables and I want to loop through pairs of them looking for variables with correlation coefficients above 0.7. I know that I can ...
user avatar
1vote
2answers
54views

Jinja2 render is not replacing variables with values

I have the following problem: key/values: .. link_1: ge0/0/1 link_2: ge0/0/2 link_3: ge0/0/3 link_4: ge0/0/4 jinja2 template: .. {%- for index in range(1,5) %} {% set line = ['link_',index]|join %} ...
user avatar
  • 11
1vote
1answer
46views

How do I loop and read PHP variables from other pages in my basic PHP website?

I have a small, simple website with a portfolio. There are five projects in the portfolio, each in its own folder. Each /portfolio/project/index.php page has a set of variables at the top, kind of ...
user avatar
1vote
1answer
23views

Run the while-loop again with the same variable and start the script again without closing it?

import random x = random.randint(0,20) y = int(input("guess the number from 0 to 20: \n")) while True: if y == x: print("well done") print(x) stoper=...
user avatar
  • 11
1vote
0answers
124views

MS Windows Batch: Use for loop with variable range and multiline commands

I'm currently trying to convince the cmd.exe to execute a for loop from a *.bat with a variable range and multiline commands. The code: @echo off SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS ...
user avatar
1vote
1answer
184views

Store a variable for a future script run, Python

I have a script that loops through file names in a json doc. In the event that there are no more filenames, I have a break statement that breaks the loop and stores the last read filename in a ...
user avatar
1vote
0answers
87views

Variable length differ in regression loop with NA values

asking for your help once again. I am trying to run a loop on the creation of different linear regressions on a given dataframe (over 400 columns). A few lines have some NA values which I try to omit ...
user avatar
1vote
0answers
141views

Ansible include_role variable scope

I have a group of database servers and I need to create specific database users on some of them. For example, I need the following: 1 readonly users on all DB servers 2 readwrite users on only ...
user avatar
  • 11
1vote
0answers
77views

passing multiple bash variables so they are next to each other in a sed command

I am trying to cycle through two files so that each combination of values is searched for in a third file. Where file 1 is the name of duplicate strings that appear in file 3: m54118_131101_153642/...
user avatar
1vote
1answer
765views

How to assign LabelEncoder to variable using loop in python

I'm trying to use the following code to assign LabelEncoder function to variables but it doesn't seem to do the job. labelencoder_first_browser=1 #Using this line as QA to see if the the value ...
user avatar
  • 633
1vote
2answers
344views

Choose rows a fixed time-interval apart in Datetime-indexed pandas dataframe

I have a pandas dataframe indexed by DateTime from hour "00:00:00" until hour "23:59:00" (increments by minute, seconds not counted). in: df.index out: DatetimeIndex(['2018-10-08 00:00:00', '2018-10-...
user avatar
  • 370
1vote
1answer
26views

How to troubleshooot Windows choice loop?

setlocal EnableDelayedExpansion :adapterloopstart echo. echo please enter the type of adapter you would like to create echo 1. Host-Only echo 2. Internal echo. set ADAPTYPE= choice /C:12 if ...
user avatar
1vote
0answers
40views

How assign a character in a lapply to eval a function in a loop r

I have a little problem to do a movement in R. This is what my data looks like: df1 <- read.csv(text="Time, Depth, Conductivity, Temperature, Pressure,Turbidity 26/04/2018 15:12:53, 1.01087, 0....
user avatar
1vote
1answer
27views

How to print a multiple characters given variable number times?

Suppose if I want to print ".|." for (2k+1) times. Below is my snippet of code. How to do that? It is throwing a syntax error. for k in range(0,n/2): print('.|.' * (2k+1))
user avatar
1vote
0answers
83views

Select an Option from a menu

I apologise if this question has already been asked, but I've searched (on both the internet and stackflow) and couldn't find a solution to my issue. I have just started learning about python ...
user avatar
  • 31
1vote
1answer
720views

VBA copy/paste range into rows below if there is a value in column a

I am trying to create a macro that will copy a range of values say B6:BM6 and paste it in the row below IF there is a value in column A. So: if column A6 is populated, copy range from rows above and ...
user avatar
  • 11
1vote
0answers
13views

changing variables within loop from outside class

I have a time class and a Build class. The harvest function increases the minerals count for the entire time, but the nunmber of minerals depends on the number of available workers. As soon as a build ...
user avatar
1vote
1answer
36views

Importing a same variable from multiple libraries from different folder

I have a folder which contains .py scripts and each contains a same variable which I need in other script if that certain script is used from that folder. folder_x main.py folder_y script1.py ...
user avatar
  • 39
1vote
0answers
31views

Bash Script Works Alone But Not When Executed From Python, Until Loop Not Recognizing Variable, Why?

I'm having no problem running the bash script from python but here's the deal... When I execute the bash script on its own, it runs fine. When I execute it from python, a variable and until loop are ...
user avatar
1vote
1answer
47views

Global variable is not being edited by function

I've done my fair share of toying around with the placement of global user within the code to see if it was missing somewhere but it does not appear to be. Basically when I call for userInstance....
user avatar
1vote
0answers
30views

SSIS Loopeach file variable not maintained

I have done a couple projects using the LoopEach construct. This the first where I'm generating an output file inside a Data Flow in the loop. I have a script that extracts the path and basename of ...
user avatar
  • 21
1vote
0answers
620views

Woocommerce auto select attributes dropdown values in loopproducts

I am trying to create a dropdown for a specific category loop page and on selecting the size from dropdown the attributes dropdown from variable products should change automatically for the category ...
user avatar
1vote
0answers
25views

How do I get my code to properly use numbers with a different amount of digits?

This program searches for the next smallest number, whose digits are in an ascending order. It works alright, but it of course doesn't work for numbers that don't have three digits, because my if-...
user avatar
1vote
0answers
24views

Loop within a loop in meta boxes

I have a question for you all! I have a post type called 'candidato', another post type called 'lista' and another post type called 'list1'. Each post type has many custom fields. In 'candidato' ...
user avatar
1vote
1answer
2kviews

GPA Calculator for python and adding to a variable in a loop?

I have to make a GPA Calculator for my class. It has to take number grades and convert them to our school's scale. It also has to determine if the class is AP or Honors. AP adds +1 the weight and ...
user avatar
1vote
2answers
83views

Perl- How can I access a variable when I set I used <STDIN> for user to set it within a loop?

I've written a script that requires the user to input a response which is saved as a variable. The problem is that I used a loop to do this and I have a second question that requires user input but ...
user avatar
  • 11
1vote
1answer
38views

How to use SSIS Foreach Loop to write to certain tables based on variable

I'm fairly new to SSIS but understand some basic concepts and have built several packages to do various tasks. I have a base table that we will call "Base" (dbo.Base) that has information in it. I ...
user avatar
  • 11
1vote
1answer
51views

Msqli query array

So I have my code function GetApi($connection,$UserId){ global $Apicall; $Apicall = array(); $Apiidquery = mysqli_query($connection, "SELECT ID FROM ` Characterapi` ...
user avatar
  • 91
1vote
3answers
5kviews

How to assign variable to value from loop VBA

my newbie question: I would need to define variable from values gathered by loop. I have column of datas, and I need to filter those data and copy to another new sheet named with variable. Problem ...
user avatar
  • 51
1vote
2answers
1kviews

How to make a loop that returns a different variable each iteration in java?

I'm trying to make a program to analyze data, but the amount of data changes each time. Here is an example output: Please enter the sample size: 3 Enter numbers for Trial 0 Enter sample #0:50 Enter ...
user avatar
1vote
1answer
101views

Compare two number's positional notation

Given two numbers. I want to compare the two numbers positional notations. Say number 1 is: 25000 Say number 2 is: 25000 And the result is the mask. If each positions match, then the mask (in this ...
user avatar
1vote
3answers
57views

writiting the code with the appropriate variable values

I should Write a program Square.java that declares and initalizes a variable n (with n ≥ 2) and prints out a two dimensional n-by-n triangular pattern as shown below (where n=6). public class Square ...
user avatar
1vote
1answer
4kviews

Multiple "Next variable" in nested if then loop

I have a code where I'm referencing variable "k" in a named range, and then performing a series of nested "if" loops. However, I can only put "next k" in one spot in the sub. However, I also need the ...
user avatar
  • 23
1vote
0answers
16views

Create different variables through a loop and execute a set of commands

I am new to python and appreciate if someone can help me out with this. I want the user to create certain number of dictionaries. Then for each dictionary I want execute specific commands. I am ...
user avatar
1vote
2answers
2kviews

Variable outside foreach loop php

I got a problem. On Wordpress I define a foreach loop, to get some informations from attached image like title, description, etc... Outside this loop, I want to call the result of various variables. ...
user avatar
  • 11
1vote
1answer
193views

Using attribute in index array method to find index always returning nil in Ruby?

Here is a simple index search based on an instance attribute for an array element: chips = [Chip.new(:white), Chip.new(:black)] color = :white idx = chips.index { |chip| chip.color == color } This ...
user avatar
  • 666
1vote
3answers
529views

How to use a for loop variable in php that is declared in javascript language

I have a little bit complicated situation with codes but I made an easy example so that It is easier for you to understand what I actually need. HTML: <html> <body> <input ...
user avatar

15 30 50 per page
1
2 3 4 5 6