0
Hi guys,it's me again š¤¦š.I need help please. I've been having problem with loops in python programming..
Here's my input . listsoffriends = ["Ojile", "Babydoo", "Grace", "jane", "Joel"] for friend in listsoffriends: print("Best wishes darling" ,friend, "do have a prosperous newyear") But the output keeps displaying with the parentheses like this. ('Best wishes darling', 'Ojile', 'do have a prosperous newyear') ('Best wishes darling', 'Babydoo', 'do have a prosperous newyear') ('Best wishes darling', 'Grace', 'do have a prosperous newyear') ('Best wishes darling', 'jane', 'do have a prosperous newyear') ('Best wishes darling', 'Joel', 'do have a prosperous newyear')
2 Answers
+ 1
If you want the output as a single string for each friend, use f-string or format method.
f-string:
```
for friend in listoffriends:
print(f"Best wishes darling {friend} do have a prosperous newyear")
```
or
format method:
```
for friend in listoffriends:
print("Best wishes darling {} do have a prosperous newyear".format(friend))
```
please note that f-string can only be use for python 3.6 and newer
0
Alright.let me try ..thank you š