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 trialMauro Y.
6,520 PointsCan I get input direct from the system shell? Like: " python script.py 2 "?
To use this value as argument for a function. Is this possible?
2 Answers
Anson Tio
5,448 PointsYes you can.
# First of all, you need to import sys
import sys
# To get all of the arguments list, you can use sys.argv
print("Number of arguments %d" % len(sys.argv))
print("Args : %s" % str(sys.argv))
Hope this example helps :D
Mauro Y.
6,520 PointsCool! This is just I wanted. Thanks!