-
Notifications
You must be signed in to change notification settings - Fork 0
/
practicing.py
90 lines (69 loc) · 1.5 KB
/
practicing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# s = 'abcdefghij'
# print(s[1:6:2])
# print(s[::1])
# print(s[::-1])
# print(s[::-2])
# print(s[3:7:-1])
# print(s[7:4:-1])
# print(s[0:1000:1])
# print(s[0:1000:2])
# print(s[-4:1:-1])
# print(s[-4:1:-2])
# print(s[5:0:1])
# # print(s[9:0:0])
# print(s[0:-10:-1])
# print(s[0:-11:-1])
# print(s[0:-12:-1])
# print(s[0:0:1])
# # print(s[0:0:0])
# print(s[0:-9:-2])
# print(s[-5:-9:-2])
# print(s[9:-1:-1])
# Q.w.a.p to reverse order of words
# s = input("Enter a string: ")
# words = s.split()
# reversed_words = words[::-1]
# result = ' '.join(reversed_words)
# print(result)
# # Q.W.A.P to reverse the content of each word
# s = input("Enter a string: ")
# words = s.split()
# result = ''
# for word in words:
# result = result + word[::-1] +''
# print(result)
# Q.w.a.p for:
# i/p:'a4k3b2'
# o/p:'aeknbd'
# s = input("Enter a string: ")
# s1 = ''
# i = 0
# while i < len(s):
# char = s[i]
# i += 1
# num_str = ''
# while i < len(s) and s[i].isdigit():
# num_str += s[i]
# i += 1
# if num_str:
# count = int(num_str)
# new_char = chr(ord(char) + count)
# s1 += new_char
# else:
# s1 += char
# print(s1)
# 2nd way
# Q.Remove duplicates from the given string?
# i/p:'ABCBABCBABCBDBABCB'
# o/p:'ABCD'
# s = input("Enter a string: ")
# s1 = ''
# for x in s:
# if x not in s1:
# s1 += x
# print(s1)
# def my_function(food):
# for x in food:
# print(x)
# fruits = ['apple', 'banana', 'cherry']
# my_function(fruits)