Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get string length
#3
I need to convert user string input to a number. My statement on line 7 isn't working:

import itertools
import sys
 
alphaNum = 'abc'
password = 'cab'
guessLength = input("How many characters would you like to guess up to: ")
int(guessLength)

 
for x in range(0, guessLength+1):
    guessList = [''.join(i) for i in itertools.product(alphaNum, repeat = x)]
    for guess in guessList:
        if (password == guess):
            print("the password is " + password)
            sys.exit()
        print(guess)
Error:
Traceback (most recent call last): File "E:/Python/Python36-32/SamsPrograms/FinalPasswordGuesser.py", line 10, in <module> for x in range(0, guessLength+1): TypeError: Can't convert 'int' object to str implicitly
What do I need to do?
Reply


Messages In This Thread
Get string length - by RedSkeleton007 - Oct-21-2017, 04:31 AM
RE: Basic string manipulation - by metulburr - Oct-21-2017, 04:37 AM
RE: Get string length - by RedSkeleton007 - Dec-04-2017, 03:15 PM
RE: Get string length - by DeaD_EyE - Dec-04-2017, 03:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can i limit length string? perrfect 3 14,104 Feb-10-2020, 04:52 PM
Last Post: Jendker
  python gives wrong string length and wrong character thienson30 2 3,022 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  Highlight/Underline a string | ValueError: zero length field name in format searching1 1 3,029 Jul-01-2019, 03:06 AM
Last Post: metulburr
  calculating length of string desul 12 8,728 May-22-2019, 10:50 AM
Last Post: ankit
  Python find the minimum length of string to differentiate dictionary items zydjohn 3 3,642 Mar-03-2018, 05:23 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020