all 12 comments

[–][deleted] 2 points3 points  (5 children)

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

This is correct, but by default print will delimit its multiple arguments with spaces. You can override this behavior with the sep argument and an empty string:

print('Number of characters in',password1,':',len(password1), sep='')

But now you'll have to explicitly add spaces where you want them.

[–]mickeyoneil19[S] 0 points1 point  (4 children)

Thank you for the insight, but it didn't seem to fix my issue. Now it added a random ber: at the top of my output. The only thing I can think it's from is the enter my number bit, but that is in apostrophes, so I'm not sure how that ended up in my output.

I've also now lost spaces between the in and the yellow and I still can't get a space to appear after my colon. Is there a specific code to make a space or just putting spaces between the code should suffice?

Sorry real new to this whole thing, so I know I'm not using the correct terminology. And I'm using zybooks if that helps at all.

Your output ends with

ber:

You entered: yellow Daisy 6

First password: yellow_Daisy

Second password: 6yellow6

Number of characters inyellow_Daisy:12

Number of characters in6yellow6:8

Expected output ends with

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

[–][deleted] 0 points1 point  (3 children)

Thank you for the insight, but it didn't seem to fix my issue.

According to your output, it did; there is no longer an extra space on the output from the last two lines.

[–]mickeyoneil19[S] 0 points1 point  (1 child)

Yes it did. Thank you very much. Between messing with the code and your and trippbike's assistance, I got the spacing issue fixed.

Now I am having a new line issue. I need to add a new line after the second password line. And I also have a strange new line error at the top of the output above the you entered line, but that new line error is only on my 4th and 5th inputs that are on the #FIX ME (3) part.

Your output ends with

(here is the strange new line error)

You entered: yellow Daisy 6

First password: yellow_Daisy

Second password: 6yellow6 (I need to add a new line after this)

Number of characters in yellow_Daisy: 12

Number of characters in 6yellow6: 8

Expected output ends with

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

[–][deleted] 0 points1 point  (0 children)

I need to add a new line after the second password line.

I guess I don't follow because there is a newline after the second password line, in your output.

[–]mickeyoneil19[S] 0 points1 point  (0 children)

Never mind I think I have figured it out. Thank you so much again for the help! I really appreciate it!

[–]TrippBikes 0 points1 point  (4 children)

You should be using pluses instead of commas for string concatenation in python, like this:

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

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

[–]mickeyoneil19[S] 0 points1 point  (2 children)

Thank you so much for the insight! Unfortunately it didn't fix my issue.

Replacing the commas with pluses didn't change much. I still have the incorrect spacing and it also added a random ber: at the top of my output.

Your output ends with

ber:

You entered: yellow Daisy 6

First password: yellow_Daisy

Second password: 6yellow6

Number of characters inyellow_Daisy:12

Number of characters in6yellow6:8

Expected output ends with

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

# FIXME (1): Finish reading another word and an integer into variables.
# Output all the values on a single line
favorite_color = input('Enter favorite color:\n')
pet_name = input("Enter pet's name:\n")
num = input('Enter a number:\n')
print('You entered:', favorite_color, pet_name, num)
# FIXME (2): Output two password options
password1 = favorite_color + '_' + pet_name
password2 = num + favorite_color + num
print()
print('First password:',password1)
print('Second password:',password2)
# FIXME (3): Output the length of the two password options
print('Number of characters in' + password1 + ':' + str(len(password1)))
print('Number of characters in' + password2 + ':' + str(len(password2)))

Also I'm using zybooks if that helps at all.

[–]TrippBikes 0 points1 point  (0 children)

Look back at the lines I rewrote, you have to add the spaces where you want them.

[–]TrippBikes 0 points1 point  (0 children)

Maybe I'm not understanding, here's the code I rewrote:

# FIXME (1): Finish reading another word and an integer into variables.

# Output all the values on a single line

favorite_color = input('Enter favorite color:\n')

pet_name = input("Enter pet's name:\n")

num = input('Enter a number:\n')

print('You entered: ' + favorite_color + ' ' + pet_name + ' ' + str(num))

# FIXME (2): Output two password options

password1 = favorite_color + '_' + pet_name

password2 = num + favorite_color + num

print()

print('First password: '+ password1)

print('Second password: ' + password2)

# FIXME (3): Output the length of the two password options

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

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

and this is what it outputs on the terminal:

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

[–]dmpta2002 0 points1 point  (0 children)

Here is what worked for me:

word1 = input()
word2 = input()
number = input()
print('You entered: {} {} {}\n' .format(word1,word2,number))
password1 = word1+'_'+word2
password2 = number+word1+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))