The code is working fine but I keep getting an EOF error on my 2nd last line.
program:
# option list for user choice
option = ['y', 'yes', 'YES', 'n', 'no', 'NO']
# invalid characters for hawaiian language
invalid_letters = {"b", "c", "d", "f", "g", "j", "q", "r", "s", "t", "v", "x", "y", "z"}
# dictionary for pronunciation of the letters of word
dictionary = {
'a' : 'ah',
'e' : 'eh',
'i' : 'ee',
'o' : 'oh',
'u' : 'oo',
'ai' : 'eye',
'ae' : 'eye',
'ao' : 'ow',
'au' : 'ow',
'ei' : 'ay',
'eu' : 'eh-oo',
'iu' : 'ew',
'oi' : 'oy',
'ou' : 'ow',
'ui' : 'ooey',
'p' : 'p',
'k' : 'k',
'h' : 'h',
'l' : 'l',
'm' : 'm',
'n' : 'n',
'w' : ['v', 'w']
}
# loop for user input
while option not in ['n', 'no']:
Alolan_word = input("Enter a hawaiian word: ").lower()
word = ' ' + Alolan_word + ' '
pronunciation = ''
skip = False

# loop for traversing the word by character wise
# match each character of word with elements of invalid_letters
for letter in Alolan_word:
if letter in invalid_letters:
print("Invalid word, " + letter + " is not a valid hawaiian character.")
break

# loop for scanning the accepted word letter wise
# match each letter of th word with corresponding pronunciation in the dictionary
for index in range(1,len(word)-1):
letter = word[index]

if skip:
skip = False
continue

if letter in {'p','k','h','l','m','n'}:
pronunciation += dictionary[letter]

if letter == 'w':
if word[index-1] in {'i','e'}:
pronunciation += dictionary[letter][0]
else:
pronunciation += dictionary[letter][1]


if letter == 'a':
if word[index+1] in {'i','e'}:
pronunciation += dictionary['ai'] + '-'
skip = True
elif word[index+1] in {'o', 'u'}:
pronunciation += dictionary['ao'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'

if letter == 'e':
if word[index+1] == 'i':
pronunciation += dictionary['ei'] + '-'
skip = True
elif word [index+1] == 'u':
pronunciation += dictionary['eu'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'

if letter == 'i':
if word[index+1] == 'u':
pronunciation += dictionary['iu'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'

if letter == 'o':
if word[index+1] == 'i':
pronunciation += dictionary['oi'] + '-'
skip = True
elif word [index+1] == 'u':
pronunciation += dictionary['ou'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'

if letter == 'u':
if word[index+1] == 'i':
pronunciation += dictionary['ui'] + '-'
skip = True
else:
pronunciation += dictionary[letter] + '-'

if letter in {"'", ' '}:
if pronunciation[-1] == '-':
pronunciation = pronunciation[:-1]
pronunciation += letter

if pronunciation[-1] == '-':
pronunciation = pronunciation[:-1]

# display the pronounciation of accepted word in hawaiian language
print(Alolan_word.upper() + " is pronounced " + pronunciation.capitalize())
option = input("Would you like to enter another word? [y/yes, n/no] ").lower()

print("All done.")

Answers

Answer 1

Answer:

Code is in the attached  .txt file

Explanation:

It must have been an indentation error since I get good results using your code properly formatted. I am not sure what the original problem was so unable to comment further


Related Questions

Hello, I desprately need help in python with this question. I have tried everything:This is the question:



4.19 LAB: Driving costs - functions

Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print('{:.2f}'.format(your_value))

Ex: If the input is:

20.0
3.1599
the output is:

1.58
7.90
63.20
Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles.

Ex: If the function is called with:

50 20.0 3.1599


This is my code:

miles_per_gallon = float(input('miles_per_gallon: '))
dollars_per_gallon = float(input('dollars_per_gallon: '))
dollars_per_mile = dollars_per_gallon/miles_per_gallon


your_value1 = 10 * dollars_per_mile
your_value2 = 50 * dollars_per_mile
your_value3 = 400 * dollars_per_mile

print('{:.2f} {:.2f} {:.2f}'.format(your_value1, your_value2, your_value3))



Can someone tell me what I'm doing incorrectly or show me? Thanks truly.



Lily

Answers

Answer:

Code is below and also attached in text file

Explanation:

Because Python indentation is extremely important and pasting code in the brainly window sometimes messes it up, I have provided code below as well as in the attached text file. If the one below works, well and good. Otherwise use the one in the text file

Let me know if you have questions

def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon):

   '''

   Equations Used:

   gallons_consumed = driven_miles/miles_per_gallon

   dollar_cost = gallons_consumed x dollars_per_gallon

   '''

   gallons_consumed = driven_miles/miles_per_gallon

   dollar_cost = gallons_consumed * dollars_per_gallon

   return dollar_cost

# Get inputs from the user

miles_per_gallon = float(input('miles_per_gallon: '))

dollars_per_gallon = float(input('dollars_per_gallon: '))

print()

#Compute dollar cost by calling the driving_cost function

for miles_driven in [10, 50, 400]:    #iterate through the list of miles

   cost = driving_cost(miles_driven, miles_per_gallon, dollars_per_gallon) #call function

   print("{:.2f}".format(cost))

   

The reduction of the amount of medication in the body can be modeled by
the equation , where A is the amount at time t, A0 is the amount at
t = 0, and k is the decay constant ( ). The half-life time of a certain
medication is 3.5 h. A person takes 400 mg of the medication at t=0, and
then additional 400 mg every 4 h. Determine the amount of the medication
in a patient’s body 23 h after taking the first dose.
After determining the value of k, define a vector
(the time since taking each dose) and calculate the corresponding values of
A. Then use MATLAB’s built-in function sum to determine the total
amount.

Answers

Answer:

hahahahahhahah

Explanation:

beacause nathonih

Other Questions
What is the answer do this please Use the given information to determine which lines if any, I'm the figure to the right are parallel. Justify each conclusion with a theorem or postulate. What is a main idea of Two Views of Project Mercury? an exploding charge applies 4000N of force on a 0.025kg bullet as it moves down a 0.5m long horizontal barrel. how much energy does the bullet have when it leaves the barrel? From sinx + cosx = 1, prove other two identities could you answer my question? thanks What is the lowest value of the range of the function shown on the graph? A. - B. - 2C. 0D. 3 Let A = (3, 4) and B = (-2, -2). Find the coordinates of Q along the directed line segment AB so that the ratio of AQ to QB is 5 to 3. name the property of a(b+(-b))=(b+(-b))a when a metal is exposed to 75.9 nm ultraviolet radiation, it emits an electron with kinetic energy 7.60 ev. what is the threshold frequency for this metal? (1.000 ev Identify whether each government policy was supported by Alexander Hamilton or Thomas Jefferson Use the Chain Rule to find dw/dt. (Enter your answer only in terms of t.)[tex]w = xe^{y/z}, x = t^{4}, y = 2 - t, z = 5 + 5t[/tex] local newspapers are typically a good source of blue-collar help and clerical employees, but they are not useful for finding any type of administrative workers. Suppose line m passes through the points (6, 10) and (1, 6) & line n passes through the points (2, -1) and (8, 5).PLA HELP URGENT NOWWWWWWWWHAT ARE LINES M AND N PERPENDICULAR, PARALLEL OR NEITHER!!!!! sojourners tend to encounter more severe culture shock when there is greater difference between their home cultures and the host culture in such factors as cultural values, language, verbal styles, and nonverbal gestures. these factors are called Please help me TwT its my last question In what phase of meiosis are tetrads of homologous pairs lined up along the center of the cell and attached to the spindle fibers? Anaphase I Metaphase II Metaphase I Anaphase II Determining Causes and Effects After people settled in the Mesopotamian region, certain developments led to the formation of the Sumerian Civilization. These developments had a cause and effect relationship. In the flow chart below, name three of these developments. The first development has been provided. True or false? data showing that the bacteria were the first lineage to diverge from the common ancestor of all living organisms suggest that the archaea and eukarya are more closely related to each other than they are to the bacteria. What do you believe are some reasons that the samurai held such a high social standing in Feudal Japan?