+ 3

Python Loop Problem

Hello, so i want to create a program that ask the user to enter a number for the start of the loop; end of the loop , and iteration/increment of the loop. is there any source code regarding with this so i can study the loopings? i can't really understand the textbook i have and this problem, i could use some help Thanks! 💙 The output i want to see from it is this: Start: 3 End: 7 Iteration: 2 3 5 The loop has stopped!

4th Oct 2021, 5:01 AM
Lia Costa ✨
Lia Costa ✨ - avatar
5 Answers
+ 5
Take three inputs and convert them to numeric types -- int or float depending on whether you want to allow numbers with decimals. Now there are two options: 1. Create a range object with the start, end, and increment values. Use a for loop to print the values. 2. Create a variable set to the start value. Use a while loop with the condition that the value of the variable is less than or equal to the end value. Inside the loop print the value of the variable then add the increment value to the variable
4th Oct 2021, 5:14 AM
Simon Sauter
Simon Sauter - avatar
+ 4
Hi, sololearn's Python course might solve your problem. start with the Python course for beginners and all yours will be clear. Answering your question, you need three integer value inputs, this is done using the following statement: int(input()). and create a for loop with the following syntax: for valeu in range(Start,end,step): #Print the values ​​here
4th Oct 2021, 5:17 AM
ErlĂŠnio.RS
ErlĂŠnio.RS - avatar
+ 3
thank you all!
4th Oct 2021, 5:24 AM
Lia Costa ✨
Lia Costa ✨ - avatar
0
the simple code is here: s=int(input('enter the start value: ')) e=int(input('enter the end value: ')) n=int(input('enter the increment you want: ')) while(s<e): print(s) s=s+n print('loop ended')
22nd Dec 2021, 11:37 AM
SANVIKA
- 2
I want to see the code maam
9th Nov 2021, 6:11 AM
Angelica Beronilla
Angelica Beronilla - avatar