无法打印部分用户名

时间:2018-02-01 14:07:23

标签: python python-2.7

i am trying to get this working but i am not getting it print 

def菜单(选择):     打印20 *' - ',' h173_37 jason proctor 12000898',20 *' - '     打印"" a":用户名'     打印"" b" :打印Exponetial'     打印"" c" :退出'     打印30 *' - '     choice = raw_input("(a,b或c):")     而选择不在[" a"," b"," c"]中:         打印"需要有价值的输入"         choice = raw_input("(a,b或c):")     返回选择

def full_name():     full_name = raw_input("输入你的全名")     return full_name

def get_first_name(full_name):

    n = (0)
    while n < len (full_name) and n != " ":
        n = n + 1
    return n

def get_last_inital(full_name):

    n = (0)
    while n > len (full_name) and n!= " ":
        n = n - 1
    return n + 1

def print_username(full_name):

    firstpart = get_first_name(full_name)
    get_first_name(full_name)== len (full_name)
    firstpart == [0,3]
    while firstpart < 3:
        firstpart+['x']
    lastpart = get_last_inital(full_name) 
    get_last_inital(full_name)== len (full_name)
    lastpart == [1,5]
    while lastpart < 5:
        lastpart+['x']

    #full_name = raw_input("enter youer full name")

    print( firstpart + lastpart + "this is your username")

#full_name()
#print_username(name)

    #def print_triangular():
        #def triangle(n):
            #return ((n**2)+2)/2.0

#n = int(raw_input('Please enter an integer: '))
#print triangle(n)


#else:

choice = 0
choice = menu(choice)    
print "You have chosen " + choice
while choice !="c":
    if choice == ("a"):
        full_name()
        def firstpart():
            firstpart()
        def lastpart ():
            lastpart()
        def print_username(full_name):
            print_username(full_name)
            username =[firstpart , lastpart]
        print "this is your username" + ("".join(firstpart , lastpart))

    #else choice ==("b"):


Pseudo code:

`get_first_name():`

 1. Set n equal to zero
 2. Loop while n is less than the length of name and the n-th character of name is not a space
 3.     Increase n by 1
 2. Return the part of name up to but not including the n-th character to the caller

`get_last_ initial():`

 1. Set n equal to the length of name minus 1
 2. While n is bigger than or equal to zero and the n-th character or name is not a space
 3. Decrease n by 1
 3. Return the part of name starting from the n+1-th character to the caller

print_username():

 1. Call get_first_name(), passing fullname, and store the first three characters in firstpart
 2. While the length of firstpart is less than three
 3.     Add an X to the end of firstpart
 4. Call get_last_name(), passing fullname, and store the first five characters in lastpart
 5. While the length of lastpart is less than five
 6.     Add an X to the end of lastpart
 7. Concatenate firstpart and lastpart, convert the resulting string to upper case and print with a helpful message

    enter code here

TypeError: join() takes exactly one argument (2 given)

1 个答案:

答案 0 :(得分:0)

如果你想让python中的函数执行,你必须调用它们,例如,你可以添加一行

print_username(name)

到文件的末尾。