Most voted "for" questions
Use this tag when the question primarily involves logic and/or command structure. Effectively, the for is a loop of repetition used to iterate matrices, vectors, or to another end that basically has three components: start, stop condition, and step, where it is usually possible to omit some of these components (although not very recommended).
Learn more…446 questions
Sort by count of
-
0
votes1
answer108
viewsHow to split a string into n equal parts in python 3.8 without using functions?
I want to split a string, in the case of a binary number, to convert into octal and Hex, but I need to divide the inserted number into equal parts, in the case of octal, I would need to divide it 3…
-
0
votes0
answers99
viewsQuestion 22. Python Wiki List BR. Repetition Structure Exercises
Ex. 21: Make a program that asks for an integer number and determines whether or not it is a prime number. Reply BY: HUGO KOTSUBO. Link: https://www.guj.com.br/t/numeros-primos/351814 Ex. 22: Change…
-
0
votes2
answers266
viewsReceive two numbers, add the pairs and multiply the odd
The program should receive two numbers, and then add all pairs between the received range, and multiply all the odd numbers of the received range (including those typed, always). Must be used for or…
-
0
votes1
answer143
viewsVector comparison program C++
You guys all right? I’m beginner and I’m trying to build a program that compares two vectors and if all the elements of the two vectors are. I’ll exemplify it to get better... vector 1 = 10, 20 , 30…
-
0
votes4
answers91
viewsHow to transform a "for" repeat code into "while" in Javascript?
var ordinais = ['primeira', 'segunda', 'terceira', 'quarta']; var media=0; for (var i = 0; i < ordinais.length; i++) { var nota = prompt("Informe a " +…
-
0
votes2
answers142
viewsJavascript tabulated result inside a DIV
I made a simple code for a table using "for" only when customizing for the result of the table to be printed in the DIV I can’t. It does not load all values. Follow the code. <!DOCTYPE html>…
-
0
votes0
answers40
viewsMy answer returns Undefined
I’m using Node to develop an application. I am making a query in the bank to pull some values. These values are: 'imagem1', 'imagem2, 'imagem3'. I want to use a for to apply a function in the 3…
-
0
votes1
answer51
viewsneed to do a function similar to a search in an agenda
Make a function that given as input a list with contact information and a string, if the string is in the list, must return contact information or contacts. Inside the entry list, you have lists…
-
0
votes1
answer40
viewsMy Javascript code loop is not working correctly
function contar() { let inicio= document.getElementById('inicio').value let fim= document.getElementById('fim').value let passo= document.getElementById('passo').value let res=…
-
0
votes1
answer48
viewsI’m having a problem running a repeat on C
Description of the issue: "Implement the function below that takes a string and compresses it into a single character, any set of consecutive repeated characters." function: char *strpack(char *s)…
-
0
votes0
answers27
viewsPython - Does not work from for
import os, sys, string # coding: utf-8 from typing import TextIO lista: TextIO = open("C:\\Users\\Eunice\\Desktop\\contas.txt", "r", encoding="utf-8") print(lista.readlines()) linha =…
-
0
votes1
answer34
viewsFor loop in R is repeating answers more times than desired
I need help for this loop that is returning more answers than desired. I made a table from the public dataset palmerpenguins and my goal is to get an estimate of the penguins' gender with missing…
-
0
votes2
answers114
viewsI’m doing a c job for college in case anyone can help
I made my code normally, but when it comes to testing it right for some and wrong for others, besides varying the answer depending on the compiler if you think the error would help a lot. #include…
-
-1
votes2
answers622
viewsRepeat loop for in C
I have to do the following exercise: Read 3 whole values and order them in ascending order. At the end, show the values in ascending order, a blank line and then the values in sequence as read. The…
-
-1
votes1
answer1359
viewsReplace wrong words in a Text Box
I wanted an idea of how to create something of the type, text field, where we type some wrong word(s) and soon is corrected(s). For example: <body><input type="text" id="exibir"…
-
-1
votes4
answers596
viewsProgressive counting using for
If I do this one: for (var i = 0; i < 9; i++) { document.write(i); } The result will be: 123456789 How do I stop instead of being like this: 123456789, it create a count with a single numeral?…
-
-1
votes1
answer493
viewsFor without the use of key
#include<stdio.h> int main ( void ){ int row; int column; for ( row = 1; row <= 7; row++ ){ for (column = 1; column <= row; column++ ) printf("*"); printf("\n"); } printf("\n"); } I want…
-
-1
votes3
answers33840
viewsC - how to calculate the factorial of a number?
I’m trying but I’m not getting it, for example: factor 5 is given by 5 * 4 * 3 * 2 * 1. You have to develop a program that calculates the factorial of an input number. (using )
-
-1
votes1
answer54
viewsWhy are the string characters being printed as integer numbers?
I have to analyze a code snippet and explain how it works, but I can’t figure out the output: Code: word_norm = 'mundo'.encode("utf8").lower() for idx, value in enumerate(word_norm): print(idx,…
-
-1
votes2
answers116
viewsIs there an alternative to using for in php?
Is there any way to do in php what the for does it differently? An alternative method for example, but with the same result that would be achieved by using the for. Example of the use of for:…
-
-1
votes1
answer60
viewsHow to make two loops for the same code just go varying the column of the courses and the columns of the questions?
I have a data.frame with lots of code in the rows and lots of columns of questions, I’m doing the simple frequency of each question I would like to know how to vary the courses and questions at…
-
-1
votes1
answer23
viewsLoop(For) doubt with information coming from the database
E ae personal blz ? I’m having a big problem executing a code of my own. I have a web application made in Windows, which is running locally. In this application I need to generate a report that is…
-
-1
votes1
answer1320
viewsHow to navigate a matrix in Matlab?
Good evening! Can anyone help me with this exercise? "Create a filename filter_matrix. m and save it to your personal account. Type a function name filter_matrix that receives a matrix as an…
-
-1
votes4
answers1878
viewsUpdating an element with Javascript
I have this code: let inicial = -0; const numeros = [1,2,3,4,5,6,7,8,9,10]; function proximo (){ inicial++ document.getElementById("lugar").innerHTML='' alert(inicial) for(let i = inicial-1; i <…
-
-1
votes2
answers62
viewsfor function in Python3 - how to print all elements of a series
i = 0 for item in test['text'][i]: print(test['text'][i]) print(i) i+=1 in my dataset "test" I have 3262 items( is a series ) however when I do "for" it "printa" only 32 items…
-
-1
votes1
answer67
viewsC# - Algorithms - For loop - Logic - Using previous value of a variable and current value of another variable
DOTNET FIDDLE Editing The following calculations correspond to actuarial calculation variables. The ages from "present age" to the age of 120 years run through the probabilities of a person’s death…
-
-1
votes1
answer42
viewsHow to assign the result of a while/for to a list so it can operate with the values
n = int(input("what range?")) f1=0 f2=1 cont = 1 while cont <= n: f3 = f1 + f2 f1 = f2 f2 = f3 if f3 % 2 == 0: print(f3) # Como eu somo os valores de f3 ou transformo ele em uma lista? cont += 1…
-
-1
votes1
answer23
viewsToogle Select function
I have the following scenario: I have a list of addresses that comes dynamically from the bank, according to what is registered by the user. I need to enable only one address, so when a button is…
javascript array angular typescript forasked 6 years, 1 month ago Henrique Mendes Silveira Rodri 367 -
-1
votes4
answers261
viewsGenerate 7 random dozens using javascript and loop for? How to do?
This is my code: function gerarDezenas() { var dezenas = ["d1","d2","d3","d4","d5","d6"]; for (var i = 0; i < dezenas.length; i++) { Math.random()*60 dezenas[i] = Math.round(Math.random() * 60…
-
-1
votes2
answers130
viewsShow Python words with 04 letters only
I’m learning Python and I’m doing an exercise, which is this one: Implement a program that asks the user for a list of words (i.e., strings) and then display on the screen, one per line, all…
-
-1
votes1
answer254
viewsMulti-entry loop for list - Python
I have a list of several tuples inside, and within tuples various elements. I need to scan all tuples on the list to capture an element that is inside each of these tuples. How can I do this? The…
-
-1
votes4
answers84
viewsShow the output of a custom vector
I have a vector with 16 elements. I want to show the elements of this vector using the repetition loop for. Output must be equal to this: A 1 2 3 4 B A 5 6 7 8 B A 9 10 11 12 B A 13 14 15 16 B As…
-
-1
votes1
answer59
viewsGave error "list index out of range" and do not understand the reason
notas = [10,5,6,7,8] for i in range(0,len(notas)+1): print(notas[i]) Made the mistake: line 4, in <module> print(notas[i]) IndexError: list index out of range…
-
-1
votes1
answer63
viewsFinite looping
I am transcribing from Java to Python a code to solve a Sudoku 4/4. When I test the code it doesn’t run and runs endlessly, apparently in one of the methods of the Artist class. Can someone help me…
-
-1
votes1
answer82
viewsUsing the FOR command
I am developing solving issues in Language C. The question asks: A palindrome is a word or phrase that has the property that can be read from right to left and from left to right. For example, the…
-
-1
votes1
answer40
viewsQuestion for in C (I’m still learning)
#include <stdio.h> int main (){ int i, n; printf("Digite um numero: "); scanf("%d", &n); int a; a = n; for ( ; a>=0; a--){ if(n%a==0){ i++; } } printf("%d", i); } This is my code, it’s…
-
-1
votes2
answers49
viewsInserting information several times
Good afternoon, I am developing a small script to organize some information that are contained in a vector, the idea is to go through two vectors, when the information of each is equal, must enter a…
-
-1
votes2
answers647
viewsFunction with for()
I have a problem in an exercise. In this exercise, I must implement a function called passandoPelosPares() that shows by the console aqui eu tenho o valor de x for each PAR value running i from 0 to…
-
-1
votes1
answer122
viewsHighlighting words from a paragraph using Javascript only
As part of learning, I’m trying to underline words that are contained in a paragraph in a document html. By my logic, I would have to store this content in a variable and then scroll through it for…
-
-1
votes1
answer54
viewsHow to reduce the number of elifs to find the letter that is most used at the beginning of the names?
lista_nomes = [] lista_idade = [] lista_sexo = [] idade_cont_menores = 0 idade_cont_maiores = 0 sexo_op = ['m', 'f'] sexo_cont_masculino = 0 sexo_cont_feminino =…
-
-1
votes1
answer108
viewsHow to use for in Javascript to view photo gallery
So, I’m still pretty weak on javascript.. I’m looking to learn more. It is a very simple code, are two "div", div thumbnail and maximized div, my CSS code displays in a floating banner the maximized…
-
-1
votes1
answer542
viewsHow to know how many times a word repeats in the array and,from the return of a function that calculates this,do new calculations?(JS)
I need to do a function that returns how many times the car board appears in the array and use this return in another function to determine a calculation. That’s my code and it’s printing "0" var…
-
-1
votes2
answers84
viewsrepetition cycle For chained, in C # Sharp, initiation
Hello, good afternoon can someone fix the program for me to be right? The goal is the program in c Harp writes is ready to receive retirement, if you have more than 60 years and more than 30 years…
-
-1
votes1
answer119
viewsJavascript: Problems running a function. How to improve code?
Hello, I am doing an introductory Javascript course and, although I can print the desired result of the exercise, the platform does not recognize my code. I would like you to help me improve the…
-
-1
votes1
answer80
viewsShow all possibilities of Python numbers
How do I show all possibilities according to the number of bit quantization, for example: user: 8 levels bits: 3 need to show then: 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 my code so far,…
-
-1
votes1
answer490
viewsError when setting values a loop "React Limits the number of renders to Prevent an Infinite loop"
Well, I have a useEffect that searches my data from an API and then set the values to a useState, but it’s entering an infinite loop and I can’t get my values in the other variable I created. export…
-
-1
votes1
answer39
viewsHow to solve the c variable problem - string capacity, start to grow exponentially from the 3rd cycle
I’m having a problem, here with a program that aims to be a data entry routine, the problem in question, is the variable c that goes to the Cap function to ask the user the maximum capacity of the…
-
-1
votes2
answers31
viewsRender different Vue.JS components within a v-for directive
I wonder how I could use a v-for to render different Vue components. I’m using Internet (I say this because I don’t know if Inertia has any function that can help). Being more specific and giving an…
-
-1
votes1
answer54
viewsDoubt in the use of the for
I need to make a code to solve the following question: I have a basket with capacity C, I have 3 types of fruit, I will receive the amount one per line, to put all of them in the basket, the…
-
-1
votes1
answer42
viewsConverting total hours of a month into days and hours
Hello! I am working on a data_set in which the time measure is in Total Hours Races of the month. Going from hour 1 to hour 734. I want to convert this measure of time into hours of the month per…