MulaiMulai sekarang secara gratis

The reduce() function

Now, it is time for some reduction! As before you'll be given three tasks to complete. Use lambda expressions!

The necessary functions from the functools module are already imported for you.

Latihan ini adalah bagian dari kursus

Practicing Coding Interview Questions in Python

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Reverse a string using reduce()
string = 'DataCamp'
inv_string = reduce(____)
print('Inverted string = ' + inv_string)
Edit dan Jalankan Kode