+ 1

I want to write Divyanshu 100 times in python

Please help

3rd Nov 2023, 3:02 PM
Menaal Anwar Fatima
Menaal Anwar Fatima - avatar
20 Antworten
+ 7
indent the last line, this is the correct code: name="Divyanshu" for _ in range(100): print (name)
3rd Nov 2023, 3:34 PM
SoloProg
SoloProg - avatar
+ 9
Menaal Anwar Fatima , before you ask for help, you should do a try by yourself first. please show your code here.
3rd Nov 2023, 3:23 PM
Lothar
Lothar - avatar
+ 3
Indentation is covered in the lesson, you can review the slides. Here is a short explanation. A for loop statement is a block statement. It consists of the "for i in range(10):", and the body which is following. And the body has to be indented. For example: for i in range(5): print(i) # it will result in error because the body "print(i)" is not indented. for i in range(5): print(i) # it will print 0, 1, 2, 3, 4 on screen because the body "print(i)" is indented. Normally we use 4 spaces for indentation, but SoloLearn use 2 spaces in their examples. It is most probably to fit the screen on mobile as more spaces will wrap the line, make it difficult to read.
3rd Nov 2023, 3:41 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 3
this place is not for getting readymade codes , here you can ask doubt and problems you faced while making a code or somthinge
4th Nov 2023, 12:09 PM
Alhaaz
Alhaaz - avatar
3rd Nov 2023, 3:26 PM
Menaal Anwar Fatima
Menaal Anwar Fatima - avatar
+ 2
Thank you
3rd Nov 2023, 4:14 PM
Menaal Anwar Fatima
Menaal Anwar Fatima - avatar
+ 2
name = “Divyanshu” print(name*100) This will print the string 100 times becaus when you multiply a string, it just duplicates.
4th Nov 2023, 1:32 PM
Lamborghini Master
+ 1
There is an indentation error. The body of the for loop is not indented.
3rd Nov 2023, 3:31 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
It's very simple add this code string_to_print = "Divyanshu" for _ in range(100): print(string_to_print) string to print is Targeted keywords
4th Nov 2023, 9:57 AM
Dipesh K Fuse
Dipesh K Fuse - avatar
+ 1
Try this : while True : print ("Divyanshu")
4th Nov 2023, 6:12 PM
chaker saidi
chaker saidi - avatar
0
Ohk
3rd Nov 2023, 3:24 PM
Menaal Anwar Fatima
Menaal Anwar Fatima - avatar
0
Didn't understand wong hei
3rd Nov 2023, 3:32 PM
Menaal Anwar Fatima
Menaal Anwar Fatima - avatar
0
As I am a beginner I don't know much
3rd Nov 2023, 3:32 PM
Menaal Anwar Fatima
Menaal Anwar Fatima - avatar
0
🙂
3rd Nov 2023, 4:14 PM
Menaal Anwar Fatima
Menaal Anwar Fatima - avatar
0
for i in range(100): print("Divyanshu")
4th Nov 2023, 4:59 AM
Bhagchand
0
It would help if it was Javascript, but it's python and I got stuck in the sequence too
4th Nov 2023, 12:03 PM
DONFY
DONFY - avatar
0
You can use a simple loop in Python to achieve this. Here's an example code to print "Divyanshu" 100 times:for _ in range(100): print("Divyanshu")This code will iterate 100 times and print "Divyanshu" in each iteration.
4th Nov 2023, 12:04 PM
রহস্যময়— পৃথিবী
রহস্যময়— পৃথিবী - avatar
0
If you want to do same task again and again you can use loops for that task here you want to print Divyanshu 100 times and for that we can use any loop I will give you the code in for loop but if you are a biggner I suggest you should try it with every type of loop the code is below for i in range(100): Print("Divyanshu")
4th Nov 2023, 5:22 PM
Mayuri Khandelwal
0
It will be print("Divyanshu"*100)
5th Nov 2023, 5:42 AM
Godson Okafor
Godson Okafor - avatar