Python Using Databases in Python Gettin' CRUD-y With It Clean Up

Dmitriy Ignatiev
Dmitriy Ignatiev
Pro Student 6,236 Points

def clear() in PyCharm

Hi there,

Could anybody clarify why def clear() doesn't work in PyCharm and how it can be solved in PyCharm?

Many thanks in advance

Johannes Scribante
Johannes Scribante
19,175 Points

Hi Dmitriy, I am using PyCharm on a Mac

import os
def clear():
os.system('cls' if == ' nt' else 'clear')

This is my code for the clear screen function, exactly like Kenneth shows in the video and the clear() function worked perfectly for me.

1 Answer

It looks like you have a space in front of " nt". try 'nt' os.system('cls' if == ' nt' else 'clear') I hope this worked! It hard to notice spaces!