Python 3.5: Invalid syntax with split('/').[-1] -


in virtual env, using python 3.5.2. when run

python file.py . below error

filename = source_path.split('/').[-1]                                       ^ syntaxerror: invalid syntax 

for code snippet

for line in lines:     source_path = line[0]     filename = source_path.split('/').[-1] 

i saw similar post op got error using python 2.7. using 3.5.2 in virtual environment. missing?

there no . before []

filename = source_path.split('/')[-1] #                               ^^ 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -