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
Grigorij Schleifer
10,365 PointsCan someone explain me the clear() function???
Hey community,
I don´t understand how this function works :(
def clear():
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
Any help is highly appreciated.
Thx
Grigorij
1 Answer
Justin Horner
Treehouse Guest TeacherHello Grigorij,
This function can be used to clear the terminal/command prompt screen based on the operating system. For Windows, the command to clear the command prompt is "cls" and the else is taking care of any other operating system by using the "clear" command.
I hope this helps.