Certainly! Here's a simple Python function that converts an input word to Pig Latin using flag-controlled looping:
```python
def convert_to_pig_latin(word):
vowels = "aeiouAEIOU"
flag = True
pig_latin_word = ""
for char in word:
if char in vowels and flag:
pig_latin_word += char
flag = False
elif char not in vowels:
pig_latin_word += char
else:
break
if not flag:
pig_latin_word += "ay"
else:
pig_latin_word += "way"
return pig_latin_word
# Example usage:
input_word = input("Enter a word: ")
pig_latin = convert_to_pig_latin(input_word)
print("Pig Latin:", pig_latin)
```
This function takes an input word and converts it to Pig Latin. It checks for the first vowel in the word and moves the consonants before the vowel to the end of the word, followed by "ay" or "way" depending on whether the word starts with a vowel or not. The flag controls the process, ensuring that it stops after the first vowel is found
Hope you understand