“Swap Case Python” Respostas de código

Convertendo letras maiúsculas em minúsculas e vice -versa em Python

s=input()
new_str=""
for i in range (len(s)):
    if s[i].isupper():
        new_str+=s[i].lower()
    elif s[i].islower():
        new_str+=s[i].upper()
    else:
        new_str+=s[i]
print(new_str)
        
        
Homeless Hawk

troca

str_swapcase = "what was that about?".swapcase()
print(str_swapcase)
rajib2k5

Troque em Python

# Python program to swap two variables

x = 5
y = 10

# To take inputs from the user
#x = input('Enter value of x: ')
#y = input('Enter value of y: ')

# create a temporary variable and swap the values
temp = x
x = y
y = temp

print('The value of x after swapping: {}'.format(x))
print('The value of y after swapping: {}'.format(y))
Amused Armadillo

Função de troca de python

def swap0(s1, s2):
    assert type(s1) == list and type(s2) == list
    tmp = s1[:]
    s1[:] = s2
    s2[:] = tmp
    
# However, the easier and better way to do a swap in Python is simply:
s1, s2 = s2, s1
Gorgeous Goshawk

Trocando maiús

# swapcase() method 

string = "thE big BROWN FoX JuMPeD oVEr thE LAZY Dog"
print(string.swapcase()) 

>>> THe BIG brown fOx jUmpEd OveR THe lazy dOG
Aggressive Addax

Swap Case Python

t = "Mr.Brown"
nt = t.swapcase()
print(nt)
Silver Takana

Respostas semelhantes a “Swap Case Python”

Perguntas semelhantes a “Swap Case Python”

Mais respostas relacionadas para “Swap Case Python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código