pimpmycamel - 11 months ago 48

Python Question

Here's my question:

Output the following to represent:

Welcome student #1, your ticket is #1001

Welcome student #2, your ticket is #1002

….

Welcome student #10, your ticket is #1010

and this is what I have so far:

`#--RAFFLE TICKETS--#`

for i in range(1001,1011): #since 1001 is inclusive and 1011 is exclusive

for j in range(1,11):

print("Welcome student #",j,"your ticket is #"+str(i))

break

but I can't get the numbers of tickets to go up to 10. I need this with both (for and while loops). Thanks in advance for any help given!

Answer

Using a for loop:

```
for i in range(1,11):
print ( "Welcome student #", i ,"your ticket is #" , 1000+i)
```

Using a while loop:

```
i=1
while i<=10:
print ( "Welcome student #", i ,"your ticket is #" , 1000+i)
i+=1
```

Source (Stackoverflow)