Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Jacek Skrzypek](https://secure.gravatar.com/avatar/b439ed236f901ef946433c8128e4c536?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jacek Skrzypek
5,040 PointsString formatting in multiline print?
Hi, I wanted to print the notification like this:
You have added bread to your list.
You have 1 item(s) on your list.
but when I tried multiline print, the string formatting wouldn't work and the notification looked like this:
"You have added", item , "to your list,"
"you have {} items on your list".format(len(shopping_list))".
So, is there a simpler way to code it than using 'print' twice, like this?:
print("You have added", item , "to your list.")
print("You have {} item(s) on your list.".format(len(shopping_list)))
Peace, Jac
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsI'm not sure it is "simpler", but you can certainly do it with one "print" statement using a formatted (f) string:
print(f"You have added {item} to your list.\nYou have {len(shopping_list)} item(s) on your list.")
This would also work, and might be easier to read:
print(f"""You have added {item} to your list.
You have {len(shopping_list)} item(s) on your list.""")
![Jacek Skrzypek](https://secure.gravatar.com/avatar/b439ed236f901ef946433c8128e4c536?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jacek Skrzypek
5,040 PointsGreat, thank you!