Have you ever wondered that you can open your drives by just typing C, D or E and then that drives are open.This can be possible by using Python. So, for performing this task this we are using os.startfile() method of OS library. This Method start a file with its associated program.
Syntax: os.startfile(file_name)
Return: None.
Now let’s see the code:
Python3
import os
query = input ( "Which drive you have to open ? C , D or E: \n" )
if "C" in query or "c" in query:
os.startfile( "C:" )
elif "D" in query or "d" in query:
os.startfile( "D:" )
elif "E" in query or "e" in query:
os.startfile( "E:" )
else :
print ( "Wrong Input" )
|
Output:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!