“Tukar di Python” Kode Jawaban

Tukar di 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

Fungsi Swap 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

Pertukaran Kasus Python

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

rfind () dalam python

#Python rfind() method finds a substring in in the string and returns the highest index. It means it returns the index of most righmost matched subtring of the string. It returns -1 if substring not found.
Spotless Spider

Jawaban yang mirip dengan “Tukar di Python”

Pertanyaan yang mirip dengan “Tukar di Python”

Lebih banyak jawaban terkait untuk “Tukar di Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya