# Tag for-loop

## [Solved] How to print out the letters of a word, one on each line, with three asterisks before and after the word

As simple as that: word = input(“Enter a word: “) print(“***”) for letter in word: print(letter) print(“***”) 0 solved How to print out the letters of a word, one on each line, with three asterisks before and after the word

## [Solved] Comparing values of a list in python with a for loop

I think this is what you mean. a = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5] b = [1, 2, 3, 4, 5] for x in a: for y in b: if a[x] == b[y]: #Do stuff…

## [Solved] for and while loop using break,pass,continue.I don’t know where I should go next [closed]

Firstly, you can simply write while True: Instead of a = True while a: Secondly, you don’t use total or t anywhere. You can delete them. Thirdly, if x has to belong to [a, b], you can write if a…

## [Solved] Extended for loop in C++

When for (int ai : a) std::cout << ai; is used for array – int a[20]; it can be substituted with for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) std::cout << a[i]; or with for (int *ai…

## [Solved] Do python support generated objects? [closed]

Some languages, you showed a python example, support generators that don’t have a return statement, they yield a value on each iteration. In Python, the statement: result = someFunc() makes result refer to a generator object, which you can then…

## [Solved] (python) why the result of this code not in right order? [closed]

X start out as apple the first iteration and then goes to cherry the secound iteration solved (python) why the result of this code not in right order? [closed]

## [Solved] Swift `for-in` loop Range and ClosedRange errors

Swift ranges are written as 0…10, not [0…10]. [0…10] creates a single-item array. The first item in the array is a 0…10 range. Using for i in [0…10] thus iterates over that single-item array, not the range itself. The iterated…

## [Solved] What does double brackets mean in this condition?

Ignoring the fact that this code results in an error, I can tell you the following. var i=0; is defining a variable named i to the value 0. flightprices[i] means the i+1th element of the array flightprices. [] notation is…

## [Solved] C++ Create Triangles with For Loops [closed]

You need to output spaces between the triangles: #include <iostream> using namespace std; int main() { const int size = 6; int uzunluk = size; for (int i = 0; i < size; i++) { for (int j = 0;…

## [Solved] What is the best way to organize a lot of data which contains multiple conditions?

You could organize your data as follows: class Program { static void Main(string[] args) { List<Criteria> list = new List<Criteria>() { new Criteria(Color.green, Country.england, Town.london, GoodBad.good, DayOfTheWeek.sunday, Daytime.evening), new Criteria(Color.red, Country.thenetherlands, Town.amsterdam, GoodBad.bad, DayOfTheWeek.monday, Daytime.night), new Criteria(Color.blue, Country.america, Town.newyork, GoodBad.bad,…

## [Solved] Triangular number pyramid in java [closed]

As explained in previous answer: StringBuilder buf = new StringBuilder(); for (int i = 1; i <= 5; i++) { buf.append(i); for (int j = 1; j <= i; j++) { System.out.println(buf); } } solved Triangular number pyramid in java…

## [Solved] how to make If statement and for loop work for an empty variable

shouldn’t it be something like this? import urllib import argparse def download_web_image(url): IMAGE = url.rsplit(“”,1)[1] urllib.urlretrieve(url, IMAGE) parser = argparse.ArgumentParser() parser.add_argument(“num1”) parser.add_argument(“num2”) parser.add_argument(“num3”) args = parser.parse_args() num3 = args.num3 if not num3: for num3 in range(01,50): download_web_image(“”.format(num1=args.num1, num2=args.num2, num3=num3)) else:…

## [Solved] How to use a loop to loop to the amount of times as a variable [closed]

The main problem with your attempt is here in the for loop. for (age = 0; age <= 19; age++) That will overwrite the age that the user entered, and always loop until it reaches 19. You want to create…

## [Solved] what happens when increment counter and test counter are interchanged in for-loop syntax? [closed]

The syntax of a for loop in C programming language is: for ( init; condition; increment ) { statement(s); } Here is the flow of control in a for loop: The init step is executed first, and only once. This…

## [Solved] How does Python iterate over a string? [duplicate]

The easiest way for me to think about this is to remember that the word ‘letter’ could easily be replaced with anything you want to call it, it’s just a placeholder. To illustrate, let’s replace ‘letter’ in your loop with…