Print newline after directory

I am trying to get a newline after the path is printed.

# Set the directory path
path = '/home/andy/Downloads'

print (path)
print /n

# Read the content of the file
files = os.listdir(path)

# Print the content of the directory
for file in files:
    print(file)

What you want is:

print()
2 Likes

You already have a newline, but to get a blank line; there’s a couple way to do it:

path = '/home/andy/Downloads'
print(path, '\n')
# or
print(path)
print()

#or
path = '/home/rob/Downloads', '\n'
print (*path)

Maybe that last one is not so useful, but it’s an option.

2 Likes
print(path, '\n')

That prints path, , .
The space at the end of the line is not usually wanted.

3 Likes

Here are basic ways of printing double newline without the unwanted space:

# as Rob has shown:
print(path)
print()

# changing the end string:
print(path, end='\n\n')

# creating a string with an additional newline:
print(f'{path}\n')
3 Likes