0

I need the username to be the first 3 letters of the users name and their age, e.g. Jack age 18 would be Jac18

name = (input('what is your name'))
age = (input('what is your age'))
username = (name+age)

what do i need to add or change to make the username only contain 3 letters of the name and the age.

user888469
  • 137
  • 2
  • 8

1 Answers1

1
name = (input('what is your name'))
age = (input('what is your age'))
if len(name) =< 3:
    username = (name+age)
else:
    username = (name[:3]+age)
Ben10
  • 500
  • 1
  • 3
  • 14
  • This makes sure that you don't try to access the first three letters of someones name, that doesn't have three letters. This would result in an error, so to prevent this you need the if statements – Ben10 Oct 03 '17 at 19:35