0
Q:

swapcase in python

x = 5
y = 10

x, y = y, x
print("x =", x)
print("y =", y)
8
str_swapcase = "what was that about?".swapcase()
print(str_swapcase)
2
Python string | swapcase()
The string swapcase() method converts all uppercase characters to 
lowercase and vice versa of the given string, and returns it. 
Here string_name is the string whose cases are to be swapped.
Parameter: The swapcase() method does not takes any parameter.
2
import re

regex = re.compile('[^a-zA-Z]')
#First parameter is the replacement, second parameter is your input string
regex.sub('', 'ab3d*E')
#Out: 'abdE'
0
Returns a list of the results after applying the given function  
to each item of a given iterable (list, tuple etc.) 
0
# Python program to demonstrate working 
# of map. 
  
# Return double of n 
def addition(n): 
    return n + n 
  
# We double all numbers using map() 
numbers = (1, 2, 3, 4) 
result = map(addition, numbers) 
print(list(result)) 
0

    x = ('key1', 'key2', 'key3')

thisdict = dict.fromkeys(x)


    print(thisdict)
#values are all None
   
0

New to Communities?

Join the community