Python Forum
Computer science can you help me with the last part of the code after mentionedWords.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Computer science can you help me with the last part of the code after mentionedWords.
#2
(Nov-26-2020, 11:16 PM)shirleylam852 Wrote: So far my code should be correct.

As I have very little knowledge what you want to accomplish I can't say for certain that your statement is incorrect. However, it is safe to say that either split() on line # 16 is redundant or your code does something which you didn't intend.

How your function cleanedup() performs: it eliminates all characters (including non-printing i.e. whitespaces, newlines, CR etc) which are not in alphabet. So result is this:


>>> cleanedup('Monty Python Flying Circus\n')
montypythonflyingcircus                                             # returns one word string
>>> cleanedup('Monty Python Flying Circus\n').split()
['montypythonflyingcircus']                                         # nothing to split on, so one item list
>>> for item in cleanedup('Monty Python Flying Circus\n').split():   
...     print(item)
...
montypythonflyingcircus
Despite the fact that I don't know what your objective is I doubt that this can be called 'correct'. To be more assistive you need to provide more information.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: Computer science can you help me with the last part of the code after mentionedWords. - by perfringo - Nov-27-2020, 08:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Having trouble with my Computer Science task Dunxx 1 1,833 Oct-07-2021, 12:32 PM
Last Post: DeaD_EyE
  computer science coursework, read the text please and tell me if theres any specifics sixcray 4 2,698 Nov-11-2020, 03:17 PM
Last Post: buran

Forum Jump:

User Panel Messages

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