0% found this document useful (0 votes)
7 views6 pages

Python String and List Operations Guide

Uploaded by

24071a6225
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Python String and List Operations Guide

Uploaded by

24071a6225
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

• Check String Palindrome:

s=input() O/P:
s=[Link](" ","").lower() Input:
if s==s[::-1]: race a car
print("Yes") Actual Output:
else: No
print("No")

• Remove Word from String:

O/P:
Input:
apple apple apple
apple
Expected Output:
Empty String

• Generate N-Bit Binary Strings:

Input:
2
Expected Output:
00
01
10
11

• Implement Set Operations:


Input:
4
1234
3
345
Expected Output:
12345
34
12
125
• Is List Sorted Checker:

Input:
5
12345
Expected Output:
True

• Duplicate Element Checker:

def has_duplicates(lst):
Duplicates found!
return len(lst) != len(set(lst))
numbers = [1, 2, 3, 4, 5, 2]
if has_duplicates(numbers):
print("Duplicates found!")
else:
print("No duplicates.")

• Capitalize First Letter of Words:

text = input("Enter a sentence: ") Enter a sentence: hello world


capitalized_text = [Link]() from python
Capitalized: Hello World From
print("Capitalized:",capitalized_te Python
xt)

• Remove Duplicates from List:

Input:
6
135371
Expected Output:
1357
• Add Commas Between Characters:

Input:
Apple
Expected Output:
A,p,p,l,e

You might also like