File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 11# Importing the required libraries.
22import pyshorteners
3+ from colorama import Fore # this module for font color
34
45# Taking input from the user.
56url = input ("Enter URL: " )
67
7- # Creating an instance of the pyshorteners library.
8- shortener = pyshorteners .Shortener ()
8+ # exception handling
9+ try :
10+ # Creating an instance of the pyshorteners library.
11+ shortener = pyshorteners .Shortener ()
912
10- # Shortening the URL using TinyURL.
11- shortened_URL = shortener .tinyurl .short (url )
13+ # Shortening the URL using TinyURL.
14+ shortened_URL = shortener .tinyurl .short (url )
15+
16+ # Displaying the shortened URL.
17+ print (f"Shortened URL: { shortened_URL } " )
18+ except (Exception ) as e :
19+ # this code runes on any error is generated by user
20+ print (Fore .RED , "Enter Valid URL format" , Fore .RESET )
1221
13- # Displaying the shortened URL.
14- print (f"Shortened URL: { shortened_URL } " )
You can’t perform that action at this time.
0 commit comments