LycanSmoke4207
LycanSmoke4207

Reputation: 9

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?

Upvotes: 0

Views: 12135

Answers (7)

mylifesboring
mylifesboring

Reputation: 1

favorite_color = input()
favorite_flower = input()
number = int(input())
print('You entered: {} {} {}\n'.format(favorite_color, favorite_flower, 
number))

password1 = (favorite_color + '_' + favorite_flower)
password2 = (str(number) + favorite_color + str(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))

This is what I got and it worked for me

Upvotes: 0

Lilly
Lilly

Reputation: 1

this is what I got: idk why but there an indentation error for password 2 & I keep getting only 3/5 points enter image description here

Upvotes: -2

Carter
Carter

Reputation: 11

heres what I got

words = input()
word2 = input()
numm = input()

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

print(f'You entered: {words} {word2} {numm}')
print(f'First password: {pw1}')
print(f'Second password: {pw2}')
print(f'Number of characters in {pw1}: {len(pw1)}')
print(f'Number of charecters in {pw2}: {len(pw2)}')

Upvotes: 0

KnowsNothing
KnowsNothing

Reputation: 1

What I came up with was:

#FIXME (1): Finish reading another word and an integer into variables. 
#Output all the values on a single line
favorite_color = input()
favorite_noun = input()
notfavorite_number = input()

print('You entered: {} {} {}\n' .format(favorite_color, favorite_noun, notfavorite_number)) 

#FIXME (2): Output two password options
password1 = [favorite_color, favorite_noun]
password2 = [notfavorite_number, favorite_color, notfavorite_number]

#strictly to add an underscore
underscore = '_'

#jonsnow
nothing = ''

#password modifications
password11 = underscore.join(password1)
password22 = nothing.join(password2) 

print('First password:', password11)
print('Second password:', password22)

#FIXME (3): Output the length of the two password options
print('\nNumber of characters in', password11 + ':', len(password11))
print('Number of characters in', password22 + ':', len(password22))

Maybe it's too much, but it worked! ¯\(ツ)

Upvotes: 0

rmazur7831
rmazur7831

Reputation: 11

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

Upvotes: 0

tresa
tresa

Reputation: 1

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

Upvotes: 0

drew wood
drew wood

Reputation: 335

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

Upvotes: 0

Related Questions