Python Forum
PigLatin Sentence Translator Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PigLatin Sentence Translator Help
#1
What I want me code to do is be able to take a sentence from a user input and output each word in that sentence in Pig Latin form. If I enter "hello there" it says ellohay, it is only printing the first word in pig latin. I am also having trouble with running code in different applications and stuff like that. It won't work in BBEdit or Terminal, but it will in JupterLab. So I would also appreciate it if any could recommend some software for a Mac because I think the software I'm using might be the problem.
def pig():
	
	sentence = input("Enter a sentence: ")
	
	
	for word in sentence.split():
	
		first_letter = word[0]
	
		if first_letter in "aeiou":
		
			word = word + "ay"
			return word
			
		else:
		
			word = word[1:] + first_letter + "ay"
			return word

		newsent = (" ".join(sentence.split()))
		print(newsent)
	

pig()
Reply


Messages In This Thread
PigLatin Sentence Translator Help - by 2skywalkers - Jun-22-2018, 09:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  (python) Can i get some help fixing a English to Morse translator? Pls AlexPython 7 1,598 Sep-12-2022, 02:55 AM
Last Post: AlexPython
  while sentence kimyyya 3 2,942 Mar-20-2021, 06:00 AM
Last Post: Pedroski55
  i want to write symbole as varibales in python to make translator rachidel07 9 3,490 Feb-03-2021, 09:57 PM
Last Post: nilamo
  List / arrays putting in sentence Kurta 3 2,556 Dec-25-2020, 11:29 AM
Last Post: Larz60+
  How to make a telegram bot respond to the specific word in a sentence? Metodolog 2 6,343 Dec-22-2020, 07:30 AM
Last Post: martabassof
  How to match partial sentence in long sentence Mekala 1 1,522 Jul-22-2020, 02:21 PM
Last Post: perfringo
  letter translator (or someting) Obsilion 4 2,445 Apr-28-2020, 12:40 PM
Last Post: deanhystad
  Remove a sentence if it contains a word. lokhtar 6 5,895 Feb-11-2020, 04:43 PM
Last Post: stullis
  I want to filter out words with one letter in a string (pig latin translator) po0te 1 2,097 Jan-08-2020, 08:02 AM
Last Post: perfringo
  Regex Help for clubbing similar sentence segments regstuff 3 2,152 Nov-20-2019, 06:46 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020