-2

I want to display a single string connected to values from a list displayed using a for loop

For example I have this:

nums = [1,2,3,4,5]
print("Numbers: ")
for i in nums:
    print(i)

but I would like it to be displayed with the 1 starting after "Numbers:"

e.g

Numbers: 1
2
3
...

How would I format the code to enable this to happen?

C.Cam
  • 65
  • 4

1 Answers1

0

Pass end='' to print():

nums = [1,2,3,4,5]
print("Numbers: ", end='')
for i in nums:
    print(i)
fferri
  • 18,285
  • 5
  • 46
  • 95