'How can I get the correct output in this program?

(1)Prompt the user to enter two words and a number, storing each into separate variables. Then, output those three values on a single line separated by a space. (2) Output two passwords using a combination of the user input. Format the passwords as shown below. (3) Output the length of each password (the number of characters in the strings).

The following is the code I am using to complete this program but I am running into an output error.

    def userdetails():
    words = input("Enter a word: ")
    word2 = input("Enter a word: ")
    numm = input("Enter a number: ")

    pw1 = words+"_"+word2
    pw2 = numm+words+numm

    print("You entered: {} {} {}" .format(words,word2,numm)) 

    print("First password:",pw1)
    print("Second password:",pw2)

    print("Number of characters in",pw1,":",len(pw1))
    print("Number of characters in",pw2,":",len(pw2))

userdetails()

Input yellow Daisy 6

Your output

Enter a word: Enter a word: Enter a number: You entered: yellow Daisy 6 First password: yellow_Daisy Second password: 6yellow6 Number of characters in yellow_Daisy : 12 Number of characters in 6yellow6 : 8

Your output does not contain You entered: yellow Daisy 6

First password: yellow_Daisy Second password: 6yellow6

I don't know what to do to get the rest of this correct for all the points needed can anyone help me?



Solution 1:[1]

I am unsure which part you are confused about. From the looks of it, the only line you are missing is print(words, word2, numm) which will complete part 1.

words = input("Enter a word: ")
word2 = input("Enter a word: ")
numm = input("Enter a number: ")

pw1 = words+"_"+word2
pw2 = numm+words+numm

print(words, word2, numm)
print(pw1)
print(pw2)
print(len(pw1), len(pw2))

Result

Enter a word: test
Enter a word: word
Enter a number: 10
test word 10
test_word
10test10
9 8

Solution 2:[2]

color = input()
flower = input()
number = input()
print('You entered: {} {} {}\n' .format(color,flower,number))


password1 = color+'_'+flower
password2 = number+color+number

print('First password:', password1)
print('Second password:', password2+'\n')


print('Number of characters in', password1+':',len(password1))
print('Number of characters in', password2+':',len(password2))

Solution 3:[3]

color = input()
word = input()
number = input()
print('You entered: {} {} {}\n' .format(color,word,number))


password1 = color+'_'+word
password2 = number+color+number

print('First password:', password1)
print('Second password:', password2+'\n')


print('Number of characters in', password1+':',len(password1))
print('Number of characters in', password2+':',len(password2))

#after multiple tests I was able to get the code formatted correctly. Thanks to stackoverflow. Thank you Tresa for the correct code. You saved me a headache. Just have to remember format, format, and more format

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 drew wood
Solution 2 tresa
Solution 3 rmazur7831