diff --git a/Images/9.png b/Images/9.png new file mode 100644 index 0000000..e0458e0 Binary files /dev/null and b/Images/9.png differ diff --git a/README.md b/README.md index 77bf4c6..5b46199 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ 1) A username is accepted and the user is asked to guess a number. The user will get 10 guesses. With every guess the interpreter will tell whether the guess is higher than or lower than the expected value. ------------------------------------------------------ +8) A string is accepted from the user as an input and the sorted string is given as the output. +------------------------------------------------------ +9) A string, tuple and list is taken as input from the user and the first and last elements of string, tuple and list are given as the output. +------------------------------------------------------ 27) A password will be generated with the following Program. ------------------------------------------------------ ## Table of Contents: @@ -14,6 +18,7 @@ | 27 | [Code](practice27.py) | [Output](Images/27.png) | 5 | [Code](practice5.py) | [Output](Images/practice5.py.jpg) | 8 | [Code](practice8.py) | [Output](Images/8.PNG) +| 9 | [Code](practice9.py) | [Output](Images/9.png) ------------------------------------------------------ ## Requirements: diff --git a/practice9.py b/practice9.py new file mode 100644 index 0000000..202cf24 --- /dev/null +++ b/practice9.py @@ -0,0 +1,10 @@ +#Exercise 9 - First-last - (Print first and last elements of inputs like strings,tuples,lists) + +def fl(seq): + return seq[:1] + seq[-1:] + +#For string +print (fl(input("Enter a string :"))) + +#For tuple and list +print(fl(eval(input("Enter a tuple or list :"))))