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.

Recommended Answers

All 4 Replies

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.")

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

thank you so much =D

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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.