0
Make a program that displays the current directory (which you are saving your programs to), the disk drive used, the system user name and the current folder. Consider the example below. Tip use the function
split
.
Diretorio Atual = C:\Users\monte\PycharmProjects\Aula3
Unidade do Disco = C:
Nome do Usuario = monte
Pasta Atual = Aula3
I tried to use the split
and the program did not accept
import os
os.getcwd()
os.getlogin()
lista = []
print(os.getcwd())
print(os.getlogin())
lista.append(os.getcwd()) #variável colocada na lista
At what point did you try to use the
split
? Why the program didn’t accept, it was wrong?– Woss
I tried using after the "list.append(os.getcwd()). error appeared:
– Homero
Traceback (Most recent call last): File "C: Users cwo Downloads list.py", line 82, in <module> list.split() Attributeerror: 'list' Object has no attribute 'split'
– Homero
The function
split
serves to break a string in pieces, you used it in a list.– Woss
appeared this result to me: C: Users cwo Downloads so I tried to use the function to separate c: from what appears
– Homero
I think that’s the answer. import os os.getcwd() os.getlogin() list = [] print('Current Directory', os.getcwd()) print('User: ', os.getlogin() list.append(os.getcwd()) list = '. Join(list) list.split() print('Disk Drive: ', list[0:2]) print('Current Folder: ', list[13:22])
– Homero