0

I am using google colab which combine the shell script and python script such as

For example

a = "test"
print(a)
!cd /content/drive/MyDrive/test

First and second line is python and third line is shell.

Now I want to use pytho variable in shell such as

a = "test"
print(a)
!cd /content/drive/MyDrive/{a}

Is it possible?

2

1 Answer 1

1

Yes. To use a variable inside a shell command with ! you can wrap it using {}

Your example is correct

Sign up to request clarification or add additional context in comments.

1 Comment

Wow , it works smoothly . thank you very much. I didn't find.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.