Hướng dẫn how to remove consonants from a string in python - cách xóa phụ âm khỏi chuỗi trong python

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Cải thiện bài viết

    Lưu bài viết

    Đọc
    Method #1 : Using loop 
    This is one of the ways in which this task can be performed. In this, we iterate through the list and then check for non presence of vowels and filter.
     

    Python3

    Bàn luận

    Đôi khi, trong khi làm việc với Python, chúng ta có thể gặp vấn đề trong đó chúng ta muốn loại bỏ tất cả các nguyên âm không khỏi chuỗi. Đây là câu hỏi và giải pháp khá phổ biến cho nó rất hữu ích trong lập trình cạnh tranh và lập trình hàng ngày. Hãy thảo luận về một số cách nhất định trong đó nhiệm vụ này có thể được thực hiện. Trong đó, chúng tôi lặp lại thông qua danh sách và sau đó kiểm tra không có sự hiện diện của nguyên âm và bộ lọc. & NBSP;

    test_str = "Gfg is best for geeks"

    print["The original string is : "

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    0
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    2=
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    4

    eeeoee - A oue iee oa o ee
    5
    eeeoee - A oue iee oa o ee
    6
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    6
    eeeoee - A oue iee oa o ee
    8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    5
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    6
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    7
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    0
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    6
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    7
    eeeoee - A oue iee oa o ee
    3
    eeeoee - A oue iee oa o ee
    4

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    2=
    eeeoee - A oue iee oa o ee
    1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee

    print[

    eeeoee - A oue iee oa o ee
    4
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    0
    eeeoee - A oue iee oa o ee
    6
    eeeoee - A oue iee oa o ee
    7
    Method #2 : Using list comprehension 
    This is one of the ways in which this task can be performed. In this, we iterate through the list and then filter out vowels in similar manner but in one-liner.
     

    Python3

    Bàn luận

    Đôi khi, trong khi làm việc với Python, chúng ta có thể gặp vấn đề trong đó chúng ta muốn loại bỏ tất cả các nguyên âm không khỏi chuỗi. Đây là câu hỏi và giải pháp khá phổ biến cho nó rất hữu ích trong lập trình cạnh tranh và lập trình hàng ngày. Hãy thảo luận về một số cách nhất định trong đó nhiệm vụ này có thể được thực hiện. Trong đó, chúng tôi lặp lại thông qua danh sách và sau đó kiểm tra không có sự hiện diện của nguyên âm và bộ lọc. & NBSP;

    test_str = "Gfg is best for geeks"

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    0
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    6
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    7
    eeeoee - A oue iee oa o ee
    3
    eeeoee - A oue iee oa o ee
    4

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    2=
    eeeoee - A oue iee oa o ee
    1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee

    print[

    eeeoee - A oue iee oa o ee
    4
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    0
    eeeoee - A oue iee oa o ee
    6
    eeeoee - A oue iee oa o ee
    7

    Đầu raO[n]

    & nbsp; Phương pháp #2: Sử dụng danh sách hiểu & nbsp; Đây là một trong những cách mà nhiệm vụ này có thể được thực hiện. Trong đó, chúng tôi lặp lại thông qua danh sách và sau đó lọc các nguyên âm theo cách tương tự nhưng trong một liner. & Nbsp;O[n]


    nguyên âm = ['a', 'e', ​​'i', 'o', 'u'].

    cho x trong c. thấp hơn[]:.

  • Nếu x trong nguyên âm:.
  • Báo chí = Báo chí. thay thế [x, ""].
  • nguyên âm = ['a', 'e', ​​'i', 'o', 'u'].

    cho x trong c. thấp hơn[]:.

    Nếu x trong nguyên âm:.

    , the task is to remove all the consonants from the string and then print the string.

    Examples:    

    Báo chí = Báo chí. thay thế [x, ""]. str= “Welcome to geeksforgeeks” 
    Output: eoe o eeoee

    Trả lại báo .. str= “What is your name?” 
    Output: a i ou ae? 

    Cải thiện bài viết Traverse all the characters of the string, if the character is a consonant then remove it from the final answer.

    Lưu bài viết

    Java

    "Gfg is best for geeks"1 =81

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9"Gfg is best for geeks"4 =85

    =88print9 =90=91

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    50
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    51

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    64 "Gfg is best for geeks"4
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    66
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    67

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print0

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    21

    eeeoee - A oue iee oa o ee
    20 "Gfg is best for geeks"16

    "Gfg is best for geeks"1 "Gfg is best for geeks"18

    eeeoee - A oue iee oa o ee
    20 "Gfg is best for geeks"16

    "Gfg is best for geeks"1 "Gfg is best for geeks"18

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9"The original string is : "8

    eeeoee - A oue iee oa o ee
    5print9 "Gfg is best for geeks"27=91
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09__150150151

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print0

    eeeoee - A oue iee oa o ee
    5
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    05

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    64 "Gfg is best for geeks"4
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    66 "Gfg is best for geeks"38

    eeeoee - A oue iee oa o ee
    5
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    29

    Độ phức tạp về thời gian: O [n] trong đó n là chiều dài của không gian chuỗi: O [1]

    Làm thế nào để bạn loại bỏ các phụ âm khỏi một chuỗi?

    Cách tiếp cận: Traverse tất cả các ký tự của chuỗi, nếu ký tự là một phụ âm thì hãy xóa nó khỏi câu trả lời cuối cùng. Dưới đây là việc thực hiện phương pháp trên: Java. Python3.

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    44
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    45

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    44
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    47
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    48
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    50
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    51

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    44
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    53

    print8"The original string is : "8

    eeeoee - A oue iee oa o ee
    5"The original string is : "8

    Bạn có thể xóa các chữ cái khỏi một chuỗi trong Python không?

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9"The original string is : "8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    64 "Gfg is best for geeks"4
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    66
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    67

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print0

    eeeoee - A oue iee oa o ee
    5
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    71

    print8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    73
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    74[1

    eeeoee - A oue iee oa o ee
    5
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    77

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9"The original string is : "8

    "The original string is : "8

    Python3

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    21

    eeeoee - A oue iee oa o ee
    20 "Gfg is best for geeks"16

    "Gfg is best for geeks"1 "Gfg is best for geeks"18

    eeeoee - A oue iee oa o ee
    5print9 "Gfg is best for geeks"27=91
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09__150150151

    "Gfg is best for geeks"1 "Gfg is best for geeks"18

    eeeoee - A oue iee oa o ee
    5print9 "Gfg is best for geeks"27=91
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09__150150151

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    81
    eeeoee - A oue iee oa o ee
    16
    eeeoee - A oue iee oa o ee
    6
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    92

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    20=
    eeeoee - A oue iee oa o ee
    222222

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    444____5
    eeeoee - A oue iee oa o ee
    46

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    5
    eeeoee - A oue iee oa o ee
    49
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    7
    eeeoee - A oue iee oa o ee
    51[
    eeeoee - A oue iee oa o ee
    53[
    eeeoee - A oue iee oa o ee
    6
    eeeoee - A oue iee oa o ee
    56

    eeeoee - A oue iee oa o ee
    5
    eeeoee - A oue iee oa o ee
    58=
    eeeoee - A oue iee oa o ee
    13
    eeeoee - A oue iee oa o ee
    61

    eeeoee - A oue iee oa o ee
    5
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    5
    eeeoee - A oue iee oa o ee
    64
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    7
    eeeoee - A oue iee oa o ee
    51[
    eeeoee - A oue iee oa o ee
    53
    eeeoee - A oue iee oa o ee
    69

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    44
    eeeoee - A oue iee oa o ee
    58=
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    95[1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    44
    eeeoee - A oue iee oa o ee
    84
    eeeoee - A oue iee oa o ee
    85

    eeeoee - A oue iee oa o ee
    5
    eeeoee - A oue iee oa o ee
    0 [
    eeeoee - A oue iee oa o ee
    89 "Gfg is best for geeks"6
    eeeoee - A oue iee oa o ee
    6
    eeeoee - A oue iee oa o ee
    929__

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print9
    eeeoee - A oue iee oa o ee
    03

    eeeoee - A oue iee oa o ee
    0
    eeeoee - A oue iee oa o ee
    05==____
    eeeoee - A oue iee oa o ee
    08
    eeeoee - A oue iee oa o ee
    09

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    6 =
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    74[1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print
    eeeoee - A oue iee oa o ee
    17
    eeeoee - A oue iee oa o ee
    6
    eeeoee - A oue iee oa o ee
    19

    C#

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    21

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    23

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    25

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    27

    "Gfg is best for geeks"1

    eeeoee - A oue iee oa o ee
    29

    "Gfg is best for geeks"4

    eeeoee - A oue iee oa o ee
    31 "Gfg is best for geeks"6"Gfg is best for geeks"7 "Gfg is best for geeks"8

    print0

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    0 print3print4 print5print6
    eeeoee - A oue iee oa o ee
    8

    eeeoee - A oue iee oa o ee
    5print9 [0[1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    0 print3[5 print5[7
    eeeoee - A oue iee oa o ee
    8

    eeeoee - A oue iee oa o ee
    5print9 [0[1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    0 print3[5 print5[7
    eeeoee - A oue iee oa o ee
    8

    "The original string is : "8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print9 "The original string is : "5[1

    print0

    "Gfg is best for geeks"4

    eeeoee - A oue iee oa o ee
    64
    eeeoee - A oue iee oa o ee
    16
    eeeoee - A oue iee oa o ee
    64
    eeeoee - A oue iee oa o ee
    67

    Các

    Các

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    64
    eeeoee - A oue iee oa o ee
    95
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    50[1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print0

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    5[
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    37 test_str 02

    eeeoee - A oue iee oa o ee
    5
    eeeoee - A oue iee oa o ee
    31 test_str 07"The original string is : "5[1

    eeeoee - A oue iee oa o ee
    5print0

    eeeoee - A oue iee oa o ee
    5
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    5[
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    37 test_str 14

    print8print0

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    44test_str 07[0[1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    44
    eeeoee - A oue iee oa o ee
    84[1

    print8"The original string is : "8

    print8

    eeeoee - A oue iee oa o ee
    0 test_str 19

    eeeoee - A oue iee oa o ee
    5"The original string is : "8

    eeeoee - A oue iee oa o ee
    5print0

    print8test_str 39

    eeeoee - A oue iee oa o ee
    5"The original string is : "8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9"The original string is : "8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print9
    eeeoee - A oue iee oa o ee
    03

    "The original string is : "8

    eeeoee - A oue iee oa o ee
    0
    eeeoee - A oue iee oa o ee
    05==____
    eeeoee - A oue iee oa o ee
    08
    eeeoee - A oue iee oa o ee
    09

    print0

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    6 =
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    74[1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9test_str 61

    "The original string is : "8

    "The original string is : "8

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    21

    test_str 64

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    23

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    25

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    27

    "Gfg is best for geeks"1

    eeeoee - A oue iee oa o ee
    29

    test_str 65"The original string is : "8

    "Gfg is best for geeks"4

    eeeoee - A oue iee oa o ee
    31 "Gfg is best for geeks"6"Gfg is best for geeks"7 "Gfg is best for geeks"8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    0 print3print4 print5print6
    eeeoee - A oue iee oa o ee
    8

    eeeoee - A oue iee oa o ee
    5=01test_str 71
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09=04
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09=06
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09=08
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09=10
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09test_str 81
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09=14
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09=16
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09=18
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09=20=21

    eeeoee - A oue iee oa o ee
    5print9 [0[1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    0 print3[5 print5[7
    eeeoee - A oue iee oa o ee
    8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print9 "The original string is : "5[1

    "Gfg is best for geeks"4

    eeeoee - A oue iee oa o ee
    64
    eeeoee - A oue iee oa o ee
    16
    eeeoee - A oue iee oa o ee
    64
    eeeoee - A oue iee oa o ee
    67

    Các

    =45test_str 07[0[1

    =45

    eeeoee - A oue iee oa o ee
    84[1

    print8"The original string is : "8

    =32"The original string is : "8

    Các

    print8test_str 39

    =32"The original string is : "8

    eeeoee - A oue iee oa o ee
    5"The original string is : "8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    64
    eeeoee - A oue iee oa o ee
    95
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    50[1

    test_str 65"The original string is : "8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    5[
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    37 test_str 02

    test_str 65

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    74[1

    test_str 65=77

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9=79

    Output:

    eeeoee - A oue iee oa o ee

    eeeoee - A oue iee oa o ee
    5
    eeeoee - A oue iee oa o ee
    31 test_str 07"The original string is : "5[1
    O[N]
    Auxiliary Space: O[N]

    eeeoee - A oue iee oa o ee
    5
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    5[
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    37 test_str 14

    print8
    eeeoee - A oue iee oa o ee
    0 test_str 19

    eeeoee - A oue iee oa o ee
    5"The original string is : "8

    =82

    eeeoee - A oue iee oa o ee
    5
    eeeoee - A oue iee oa o ee
    0 test_str 35

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print0

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    64 "Gfg is best for geeks"4
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    66 test_str 51
    eeeoee - A oue iee oa o ee
    644____453

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9"The original string is : "8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    eeeoee - A oue iee oa o ee
    64 test_str 57
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    74[1

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print0

    eeeoee - A oue iee oa o ee
    5"Gfg is best for geeks"05
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    74[1

    eeeoee - A oue iee oa o ee
    5"Gfg is best for geeks"09

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9"The original string is : "8

    "The original string is : "8

    C#

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    21

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    23

    eeeoee - A oue iee oa o ee
    20
    eeeoee - A oue iee oa o ee
    25

    print0

    eeeoee - A oue iee oa o ee
    5
    eeeoee - A oue iee oa o ee
    0 test_str 35

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print0

    eeeoee - A oue iee oa o ee
    5print9 "Gfg is best for geeks"27=91
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    09__150150151

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9"The original string is : "8

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    64 "Gfg is best for geeks"4
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    66 "Gfg is best for geeks"38

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9print0

    eeeoee - A oue iee oa o ee
    5"Gfg is best for geeks"05
    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    74[1

    eeeoee - A oue iee oa o ee
    5"Gfg is best for geeks"46

    The original string is : Gfg is best for geeks
    String after consonants removal : ieoee
    9"The original string is : "8

    "The original string is : "8

    Output:

    eeeoee - A oue iee oa o ee

    Độ phức tạp về thời gian: O [n] trong đó n là chiều dài của không gian chuỗi: O [1] O[n] where n is the length of string
    Auxiliary Space: O[1]


    Làm thế nào để bạn loại bỏ các phụ âm khỏi một chuỗi?

    Cách tiếp cận: Traverse tất cả các ký tự của chuỗi, nếu ký tự là một phụ âm thì hãy xóa nó khỏi câu trả lời cuối cùng.Dưới đây là việc thực hiện phương pháp trên: Java.Python3.Traverse all the characters of the string, if the character is a consonant then remove it from the final answer. Below is the implementation of the above approach: Java. Python3.

    Bạn có thể xóa các chữ cái khỏi một chuỗi trong Python không?

    Bạn có thể xóa một ký tự khỏi chuỗi python bằng cách sử dụng thay thế [] hoặc dịch [].Cả hai phương thức này thay thế một ký tự hoặc chuỗi bằng một giá trị đã cho.Nếu một chuỗi trống được chỉ định, ký tự hoặc chuỗi bạn chọn sẽ bị xóa khỏi chuỗi mà không cần thay thế.. Both these methods replace a character or string with a given value. If an empty string is specified, the character or string you select is removed from the string without a replacement.

    Làm thế nào để bạn loại bỏ tất cả các phụ âm trong Python?

    Loại bỏ các phụ âm và nguyên âm từ một chuỗi trong câu trả lời của mã Python..
    def anti_vowel [c]:.
    Báo chí = C ..
    nguyên âm = ['a', 'e', 'i', 'o', 'u'].
    cho x trong c.thấp hơn[]:.
    Nếu x trong nguyên âm:.
    Báo chí = Báo chí.thay thế [x, ""].
    Trả lại báo ..

    Bài Viết Liên Quan

    Chủ Đề