Python Forum
Why isnt this word length selector working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why isnt this word length selector working
#7
Please do not PM members for answers, it defeats the purpose of the forum.

Your code is quite difficult to follow, using to similar variable names, for instance 'word' and 'words'.  Be inventive, instead use something like 'word_list = ', 'random_word = ' and so on.  Also, you don't want to use Python words as variables, for example, 'index' is a list attribute

my_list = [1, 2, 3]
my_list.index(1)    # Will return '0'.  Remember, indexes start with '0', not '1' 
Your problem lies in your while/try/except clause.  So as nilamo suggested, where would be a good place (or places) to put a 'print' to test the value of the variable that puts you there?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Messages In This Thread
RE: Why isnt this word length selector working - by sparkz_alot - Mar-26-2017, 08:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Working with Excel and Word, Several Questions Regarding Find and Replace Brandon_Pickert 4 1,576 Feb-11-2023, 03:59 PM
Last Post: Brandon_Pickert
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,527 Aug-12-2021, 04:25 PM
Last Post: palladium
  Looping if condition isnt met finndude 6 2,980 May-03-2021, 08:01 PM
Last Post: Skaperen
  Python Speech recognition, word by word AceScottie 6 16,045 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  print a word after specific word search evilcode1 8 4,881 Oct-22-2019, 08:08 AM
Last Post: newbieAuggie2019
  for some reason this isnt working lokchi2017 3 2,713 Aug-06-2018, 12:24 PM
Last Post: perfringo
  average word length syn09001 6 12,537 Jul-18-2018, 08:26 PM
Last Post: micseydel
  difference between word: and word[:] in for loop zowhair 2 3,690 Mar-03-2018, 07:24 AM
Last Post: zowhair
  ISO working example of opening a Microsoft Word document through PyWin32 Orthoducks 1 4,619 Dec-25-2016, 10:12 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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