Permalink
Không thể lấy lại những người đóng góp tại thời điểm này
Tệp này chứa văn bản unicode hai chiều có thể được giải thích hoặc biên dịch khác với những gì xuất hiện dưới đây. Để xem xét, hãy mở tệp trong một trình soạn thảo cho thấy các ký tự Unicode ẩn. Tìm hiểu thêm về các ký tự unicode hai chiều
deffirst_non_repeating_letter [chuỗi]: first_non_repeating_letter[string]: | |
#mã của bạn ở đây | |
printString string | |
Danh sách = [i.lower [] foriinString] = [i.lower[] for i in string] | |
Danh sách in list | |
foriinrange [Len [danh sách]]: i in range[len[list]]: | |
iflist.count [danh sách [i]] == 1: list.count[list[i]] == 1: | |
trở lại [i] string[i] | |
return"" "" |
Permalink
Không thể lấy lại những người đóng góp tại thời điểm này
Tệp này chứa văn bản unicode hai chiều có thể được giải thích hoặc biên dịch khác với những gì xuất hiện dưới đây. Để xem xét, hãy mở tệp trong một trình soạn thảo cho thấy các ký tự Unicode ẩn. Tìm hiểu thêm về các ký tự unicode hai chiều
# Xem //www.codewars.com/kata/52bc74d4ac05d0945d00054e/train/python | |
deffirst_non_repeating_letter [chuỗi]: first_non_repeating_letter[string]: | |
StringCopy = "". Tham gia [[x.lower [] ForxInstring]] = "".join[[x.lower[] for x in string]] | |
forsinstringcopy: s in stringCopy: | |
ifStringCopy.Count [s] == 1: stringCopy.count[s] == 1: | |
ifs.isalpha []: s.isalpha[]: | |
ifsinstring: trả về s in string: return s | |
ifs.upper [] Hướng dẫn: return.upper [] s.upper[] in string: return s.upper[] | |
khác:: | |
trả lại s | |
return"" "" | |
FromTestFunctionImportTest TestFunction import Test | |
test = test [none] = Test[None] | |
test.describe ['Bài kiểm tra cơ bản'].describe['Basic Tests'] | |
# test.it ['nên xử lý các bài kiểm tra đơn giản'] | |
test.assert_equals [first_non_repeating_letter ['a'], 'a']].assert_equals[first_non_repeating_letter['a'], 'a'] | |
test.assert_equals [first_non_repeating_letter ['stress'], 't']].assert_equals[first_non_repeating_letter['stress'], 't'] | |
test.assert_equals [first_non_repeating_letter ['moonmen'], 'e']].assert_equals[first_non_repeating_letter['moonmen'], 'e'] | |
# test.it ['nên xử lý các chuỗi trống'] | |
test.assert_equals [first_non_repeating_letter [''], ''].assert_equals[first_non_repeating_letter[''], ''] | |
# test.it ['nên xử lý tất cả các chuỗi lặp lại'] | |
test.assert_equals [first_non_repeating_letter ['abba'], ''].assert_equals[first_non_repeating_letter['abba'], ''] | |
test.assert_equals [first_non_repeating_letter ['aa'], ''].assert_equals[first_non_repeating_letter['aa'], ''] | |
# test.it ['nên xử lý các ký tự lẻ'] | |
test.assert_equals[first_non_repeating_letter['~>.assert_equals[first_non_repeating_letter['~>
Chủ Đề |