+ 2
How to make it easy?
nums = ["1" , "2" , "3" , "4" , "5"] for num in nums: print(num + "." + "" + " I will complete my homework regularly.") Output of this code :- 1. I will complete my homework regularly. 2. I will complete my homework regularly. 3. I will complete my homework regularly. 4. I will complete my homework regularly. 5. I will complete my homework regularly. In this I want this same to be continued till 100 times but I have to write numbers till 100 in 1st code of line in input but it is not a very easy task. So , I want some suggestions to make it easy. (for example I think somehow we can use while loops/for loops, but again how?)
4 Answers
+ 4
for n in range(1, 101):
print(n, ".", sep="", end="")
print(" I will complete my homework regularly.")
# Keep learning & happy coding :D
+ 1
Instead of nums , you can use range() function
for num in range(10) :
print(str(num)+"...")
see lesson number 28.1: from python core
https://www.sololearn.com/learning/2434/
+ 1
Kunj Mandaviya I given you code only how to write.
oh .Yes. sry ,There is a mistake that it can't add a number to string , but I thought you did it in your list so you can do it. I don't checked it.
Now I updated to print(str(num)+"text..") works but check Identation. Iam not tested. But it works ..
+ 1
Jayakrishna yeah, thanks
it works now đ