Skip to content
Advertisement

Using a variable as a Filename Python

I cannot get using a variable in the filename to work without throwing an error.

JavaScript

I have tried formatting the string as shown above as well as concatenating the variables.

Is there anything I can do to solve this?

Advertisement

Answer

One issue was the closing parentheses, also the date format contain / (slash ex:07/07/21) which will make the filename with slash i.e not a valid name in windows as it makes it a path.

Solution with least change to your logic:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement