Mohamed Farahat نشر 27 أبريل أرسل تقرير مشاركة نشر 27 أبريل (معدل) مرحبا, I've been stuck on this problem for a while. Could someone help me, please? Thank you in advance def convert_to_snake_case(pascal_or_camel_cased_string): snake_cased_char_list = [] for char in pascal_or_camel_cased_string: if char.isupper(): converted_character = '_' + char.lower() snake_cased_char_list.append(converted_character) else: snake_cased_char_list.append(char) snake_cased_string = ''.join(snake_cased_char_list) clean_snake_cased_string = snake_cased_string.strip('_') return clean_snake_cased_string def main(): pass Inside the main() function, replace pass with a convert_to_snake_case() call. Pass the string 'aLongAndComplexString' as input to the function and print out the output using the print() function. تم التعديل في 27 أبريل بواسطة Mohamed Farahat 1 اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
0 Chihab Hedidi نشر 27 أبريل أرسل تقرير مشاركة نشر 27 أبريل الحل الخاص بك صحيح و إنما فقط ينقصك أن تستعمل الدالة و إعطائها الجملة aLongAndComplexString كمدخلات و تطبع النتيجة و للقيام بذلك يمكنك التعديل على main، و يمكنك القيام بذلك لوحدك عليك المحاولة أكثر، ما تحتاج القيام به هو تعريف مثلا متغير داخل main هكذا input_string = 'aLongAndComplexString' بعدها استدعيه داخل الدالة ليتم تطبيق التغييرات عليه و إطبع النتيجة، و يمكنك أن تطلع أكثر على كيفية عمل الدوال من هنا: 1 اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
0 Mohamed Farahat نشر 27 أبريل الكاتب أرسل تقرير مشاركة نشر 27 أبريل def main(): input_string = 'aLongAndComplexString' print(input_string) Sorry, your code does not pass. Keep trying. You should call convert_to_snake_case() inside the main() function and pass 'aLongAndComplexString' as input to the function. Just got it thank you for your help def main(): convert_to_snake_case() my_function("Input String") print(convert_to_snake_case('aLongAndComplexString')) 1 اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
السؤال
Mohamed Farahat
مرحبا,
I've been stuck on this problem for a while. Could someone help me, please? Thank you in advance
Inside the main() function, replace pass with a convert_to_snake_case() call. Pass the string 'aLongAndComplexString' as input to the function and print out the output using the print() function.
تم التعديل في بواسطة Mohamed Farahatرابط هذا التعليق
شارك على الشبكات الإجتماعية
2 أجوبة على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.