python beginner here. I'm trying to create a script that recursively renames files in a folder according to set rules (no spaces, numbers, no special characters...). For that, I ask the user, by choosing in a list (all using inquirer) how they wants to rename their files. The problem is that I can't use the user's answers with inquirer. Here is the code:
import os
import re
import inquirer
def space():
for file in os.listdir("."):
filewspace = file.replace(" ","")
if(filewspace != file):
os.rename(file,filewspace)
def numbers():
for file in os.listdir("."):
os.rename(file, file.translate(str.maketrans('','','0123456789')))
questions = [
inquirer.List('choices',
message="How do you want to format?",
choices=['Remove spaces', 'Remove numbers',
'Remove specials',],
),
]
answers = inquirer.prompt(questions)
if (answers) == "space":
space()
elif (answers) == "numbers":
numbers()
#else:
#specials()
When I try to print what is inside "answers" after the user choice, I get this back: https://i.stack.imgur.com/UrraB.jpg
I'm stuck at it... Can anyone help, please?