Hey
As my title sais having issues getting characters (like names and such ) in my code. I can only get numbers
Any help would be appreaciated

print ("Program 2: Using Inputs")
#prints the title
print ("Author: Benoit Labelle")
#prints the author's name
print ("ID: 3065521")
#prints the authors id number
loop=1
choice=0
while loop==1:
     print "This program will add your first name to your last name, and then multiply your two favorite numbers in a select      order"
     print "Option 1: First name, Last Name, Numbers"
     print "Option 2: Numbers, First Name Last Name"
     print "Option 3: Exit"
     choice = int(raw_input("Choose your option: ").strip())
     if choice ==1:
          fn=raw_input("please select your first name")
          ln=raw_input("Please select your Last Name")
          fnbr=input("please select your favorite number")
          sfnbr=input("please select your second favorite number")
          print fn, ln
          print fnbr * sfnbr
      elif choice==2:
          fnbr=input("please select your favorite number")
          sfnbr=input("please select your second favorite number")
          fn=raw_input("please select your first name")
          ln=raw_input("Please select your Last Name")
          print fnbr * sfnbr
          print fn, ln
      elif choice == 
          3: loop = 0
print "thank you"
# fn = first name
#ln = last name
# fnbr = favorite number
# sfnbr = secodn favorite number

Any help would be greatly appreaciated, with explanations why so i dont make this stupid mistake again

Thanks

Ben
"live life at it's fullest"

In Python2 input() is for numbers and raw_input() is for strings. It is best to use raw_input() and then convert to a number using int() or float() since input() uses eval() internally and that can also excute commands. Some evil genius might whipe out your diskdrive this way.

Short example:

name = raw_input("Enter your name: ")
number = int(raw_input("Enter you favorite integer number: "))
div = float(raw_input("What is 3 divided by 2? "))

print('-'*10)  # print 10 dashes
print(name)
print(number)
print(div)
print('-'*10)
# optionally format via % specifier
sf = """
name         = %s
favorite int = %d
3 div by 2   = %f
"""
print(sf % (name, number, div))

''' example output -->
Enter your name: Henri
Enter you favorite integer number: 7
What is 3 divided by 2? 1.5
----------
Henri
7
1.5
----------

name         = Henri
favorite int = 7
3 div by 2   = 1.500000

'''

Your program works fine for me, after correcting some indentation errors, on Python2.7. Show us what the program prints.

def enter_names():
    fn=raw_input("please select your first name ")
    ln=raw_input("Please select your Last Name ")

    return fn, ln

def enter_numbers():
    fnbr=input("please select your favorite number ")
    sfnbr=input("please select your second favorite number ")

    return fnbr, sfnbr

loop=1
choice=0
while loop==1:
     print
     print "This program will add your first name to your last name, and then multiply your two favorite numbers in a select      order"
     print "Option 1: First name, Last Name, Numbers"
     print "Option 2: Numbers, First Name Last Name"
     print "Option 3: Exit"
     choice = int(raw_input("Choose your option: ").strip())
     if choice ==1:
          fn, ln = enter_names()
          fnbr, sfnbr = enter_numbers()
          print fn, ln
          print fnbr * sfnbr
     elif choice==2:
          fnbr, sfnbr = enter_numbers()
          fn, ln = enter_names()
          print fnbr * sfnbr
          print fn, ln
     elif choice == 3: 
        loop = 0

print "thank you"

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.