我正在做一个猪拉丁项目,这需要改变任何句子输入的用户被翻译成猪拉丁。我有转换下来,它的工作。然而,我对标点符号有一些问题。当我拆分字符串以处理字符串中的每个单词时,标点符号会成为障碍。我想知道一种方法,能够将字符串输入拆分成单独的单词,但是保留分隔符,然后能够正确地放回标点符号和空格?public static void main(String[] args) { System.out.print("Enter a word or phrase: ");
Stri
'''PigLatin is a language constructed by transforming English words.The• If the word begins with a consonantThen your program should
translate the line into PigLatin
x = input("Type phrase or word you would like to be translated to piglatin:")y = x.split()n = len(y) -1 first_word = y.pop(a)
pig_latin = first_word[1:len(first_word)] + first_word[0] + "a