Python Forum
invalid syntax - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: invalid syntax (/thread-11364.html)



invalid syntax - lokchi2017 - Jul-05-2018

this code should be okay, but when i run it it says "invalid syntax."
Code:
youtuber = input("Name a YouTuber!")
subs = input("How many subs?")
print (youtuber + "is a YouTuber with" + subs "subscribers")
please help, thank you.


RE: invalid syntax - buran - Jul-05-2018

the problem is subs "subscribers" - missing +
however better start using string formatting, e.g.
print("{} is a YouTuber with {} subscribers".format(youtuber, subs))
or in python 3.6+, using f-string

print(f"{youtuber} is a YouTuber with {subs} subscribers")