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')

3rd Jan 2022, 6:48 PM
Glory Isah
2 odpowiedzi
+ 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
3rd Jan 2022, 6:54 PM
Shahrull Fytri
Shahrull Fytri - avatar
0
Alright.let me try ..thank you 🙏
3rd Jan 2022, 7:02 PM
Glory Isah