Placeholders in Python: placing multiple names in an array

Question:

I am a beginner in python and learning “Learn Python: The Complete Python Programming Course” using Udemy. I downloaded Python 3.8. All things were good until I reached placeholders:

for i in arr.
Print(sen%(ā€œiā€))

I just want to use the function of placeholders in python and complete the task by placing multiple names in an array. I cannot type any of this. May I know why?

I am stuck and can’t move ahead in the learning of the course.

My work

As the course says

Asked By: Haneef

||

Answers:

Try:

for i in arr:
    print(sen%(i))

That is, replace arr. to arr:

Answered By: Joshua Varghese

It is a bit finicky and will throw an error if the statement isn’t lined up correctly, if you hit return in the wrong spot, or put a space where there shouldn’t be one.

  1. As @Joshua Varghese suggested, first change arr. to arr:
  2. Make sure there is no space in arr:print(sen%(i))
  3. Put your curser just before print(sen%(i)), and hit return. (This will put your print statement on the next line with the correct spacing).
  4. To have your program execute and iterate through the array of names, you need to have your curser on the next line, the line following print(sen%(i)), then hit return.

Note: using python 3.9.2 on Mac OS

Answered By: Nik
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.