0

Starting on basic functions for python, and this is a assignment that I have to do... but I keep getting a Error.. but I tried, and still don't understand what is wrong. here is what it's suppose to output:http://i39.tinypic.com/r1mv69.jpg

This is what I've done:

def function1(french):
    print "Bonjour, comment allez-vous ?"

def function2():
    print "Hola, cómo esta usted?"

def function3():
    print "Hello, hoe zijn u?"

def function4():
    print "Hallo, wie geht es Ihnen?"

#main

print\
"""
Hello, how are you?

while True:
    choice = input("Enter a language: (french, spanish, greek, dutch")
    if choice == french:
         function1(french)
         prints "Hallo, wie geht es Ihnen?"
    elif choice ==spanish:
         function2()
    elif choice == greek:
         function3()
    elif choice == dutch:
         function4()
    else:
         print "You have to choose from french, spanish, greek or dutch!"

raw_input("\n\nPress the enter key to exit.")

Please help, thank you so much.
The teacher wants it so the user can ONLY type the choice and no numbers.

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by Paul Thompson
0

You are almost there, but you have to tell Python about all those foreign characters using a 'coding line' in the beginning of your code ...

# -*- coding: iso-8859-15 -*-
# check encoding in http://www.python.org/dev/peps/pep-0263/

def function1():
    print "Bonjour, comment allez-vous ?"

def function2():
    print "Hola, cómo esta usted?"

def function3():
    print "Hello, hoe zijn u?"

def function4():
    print "Hallo, wie geht es Ihnen?"

#main

print "Hello, how are you?"

while True:
    choice = raw_input("Enter a language (french, spanish, greek, german): ")
    if choice == "french":
         function1()
    elif choice == "spanish":
         function2()
    elif choice == "greek":
         function3()
    elif choice == "german":
         function4()
    else:
         print "You have to choose from french, spanish, greek or german!"

raw_input("\n\nPress the enter key to exit.")
0

Wow, thank you. o_o
I would've never gotten that....

thank you so much =D

0

Just a thought, i cant see how it breaks out of the loop, so maybe move the other raw_input() in a bit:

# -*- coding: iso-8859-15 -*-
# check encoding in http://www.python.org/dev/peps/pep-0263/

def function1():
    print "Bonjour, comment allez-vous ?"

def function2():
    print "Hola, cómo esta usted?"

def function3():
    print "Hello, hoe zijn u?"

def function4():
    print "Hallo, wie geht es Ihnen?"

#main

print "Hello, how are you?"

while True:
    choice = raw_input("Enter a language (french, spanish, greek, german): ")
    if choice == "french":
         function1()
    elif choice == "spanish":
         function2()
    elif choice == "greek":
         function3()
    elif choice == "german":
         function4()
    else:
         print "You have to choose from french, spanish, greek or german!"

    if raw_input("\n\nPress the enter key to exit.") == '':
        break
0

Just a thought, i cant see how it breaks out of the loop, so maybe move the other raw_input() in a bit:

# -*- coding: iso-8859-15 -*-
# check encoding in http://www.python.org/dev/peps/pep-0263/

def function1():
    print "Bonjour, comment allez-vous ?"

def function2():
    print "Hola, cómo esta usted?"

def function3():
    print "Hello, hoe zijn u?"

def function4():
    print "Hallo, wie geht es Ihnen?"

#main

print "Hello, how are you?"

while True:
    choice = raw_input("Enter a language (french, spanish, greek, german): ")
    if choice == "french":
         function1()
    elif choice == "spanish":
         function2()
    elif choice == "greek":
         function3()
    elif choice == "german":
         function4()
    else:
         print "You have to choose from french, spanish, greek or german!"

    if raw_input("\n\nPress the enter key to exit.") == '':
        break
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.