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 trialMichael Higginbotham
8,107 Pointsi'm getting an error on my code and do not no why, code is the same from the video but i'm receiving File"<stdin>",
input_string = input("What string do you want to use? ")
input_int = input("How many times should I repeat it? ")
print(input_string * int(input_int))
python string_multiply.py
File "<stdin>", line 1
python string-multiply.py
^
SyntaxError: invalid syntax
2 Answers
Kenneth Love
Treehouse Guest TeacherJudging by the traceback/error that you posted, there's a line like python string-multiply.py
as the first line in your string_multiply.py
file. That's throwing a syntax error.
james bush
4,688 PointsI got the same error. This is my file -- no "python string-multiply.py" line:
treehouse:~/workspace$ cat string_multiply.py
input_string = input("What string do you want to use? ")
input_int = input("How many times should I repeat it? ")
print(input_string*int(input_int))
Kenneth Love
Treehouse Guest TeacherAnd when you run it like:
treehouse:~/workspace$ python string_multiply.py
You get the same SyntaxError
?
james bush
4,688 PointsYeah, the program works when run like that.
My problem was attempting to start string_multiply.py inside Python with command "python programName.py".
Kenneth Love
Treehouse Guest TeacherWell, yeah...you can't run a Python program from inside of Python. If you had all of that code inside of a function, you could call the function and it would run. You have to leave the Python shell to run a separate Python program.
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherI edited your post for syntax highlighting. Can you confirm that it looks correct?