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.
Answers:
Try:
for i in arr:
print(sen%(i))
That is, replace arr.
to arr:
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.
- As @Joshua Varghese suggested, first change arr. to arr:
- Make sure there is no space in
arr:print(sen%(i))
- 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).
- 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
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.
Try:
for i in arr:
print(sen%(i))
That is, replace arr.
to arr:
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.
- As @Joshua Varghese suggested, first change arr. to arr:
- Make sure there is no space in
arr:print(sen%(i))
- 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). - 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