Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Search results

  1. hanginthere

    Python Python

    You could just use a text editor that supports regular expressions, such as TextPad, and replace "^" with the required string. Or, if there are just a small number of lines (you didn't say), just insert the string on the first line, then select/copy and repeatedly paste (CTRL-V) at the start of...
  2. hanginthere

    Python Check whether a whole number plus Numeric Numbe

    But then you'd also have to check for .00, .000, etc. Better to just convert to int and compare. Even a basic example should satisfy the specs.
  3. hanginthere

    Python Check whether a whole number plus Numeric Numbe

    @menator You return False if arg is a float. A value of 2.0 would qualify as a whole number.
  4. hanginthere

    Python Check whether a whole number plus Numeric Numbe

    I'm assuming you posted this for feedback. "check" is a very non-descriptive name for a function. It should be renamed to something like "isWholeNum". Your type hint on the def says it returns a boolean value, yet in line 3 you return "Whole number". You don't need to import typing. There is...
  5. hanginthere

    Python Check whether a whole number plus Numeric Numbe

    One way to check if a numeric value is a whole number is if int(num) == num: To check if a value can be converted to a numeric without using a "try" you can do if type(value) in (int, float):
  6. hanginthere

    Python Does anyone know why this happens?

    Just a suggestion, I find it is easier to use an implicit context manager. That way you never have to worry about closing a file. For example: for line in open('dictionary.txt'): dictionary_list.append(line.strip()) The file is automatically closed when the loop terminates. Also, when...
  7. hanginthere

    Python Can anyone help me with this?

    You type in exactly what you see. number = input("Please enter a number: ") prints the quoted string, then waits for you to type something and press enter. The string you type gets stored in the variable, number. While this is not strictly correct, you can just assume that it is for now. Note...
  8. hanginthere

    Python Check if two strings are anagrams (video)

    After one minute of pointless music and text that was hard to read, and no idea how what I was seeing related to anagrams I called it quits. You don't need a video to demonstrate (poorly) that which can be explained with four lines of code and two lines of text.
  9. hanginthere

    Python Number Hi-Low game.

    Getting back to the original thread - what are the rules for the game?
  10. hanginthere

    Python Number Hi-Low game.

    Except for syntax errors, what the error is depends on what you want the program to do. What do you want for your output? If you are getting an error, what is the error message and what line is causing it?
  11. hanginthere

    Python Number Hi-Low game.

    It's not final until it is documented. Perhaps you could provide a short description of what you program does and how it is used.
  12. hanginthere

    Python Write in lines from a txt that is called by the occurrence of two strings

    Well, if the OP has lost interest then I suppose I have as well.
  13. hanginthere

    Python Write in lines from a txt that is called by the occurrence of two strings

    Your original spec says "write all the lines between them but only if its input lines lines optmized". According to the spec the output should only be the following starred lines input *lines *lines optimized input lines lines input *lines *lines optimized input lines lines another lines lines...
  14. hanginthere

    Python Write an empty line at the end of my files

    First of all I apologize for the typos in the previous post. Perhaps you could tell me what you actually want the code to do. My interpretation is: You have a set of n files dipole_1.com dipole_2.com . . . dipole_n.com and a file, innput.txt. You want to read...
  15. hanginthere

    Python Write an empty line at the end of my files

    What am I missing? The code write one file terminated by a new line. Call it repeatedly for a bung of files.
  16. hanginthere

    Python Write an empty line at the end of my files

    How about trying with open('output.txt', 'w') as out: for line in open('input.txt'): out.write(line) out.write('\n')
  17. hanginthere

    Python Change values in one list by referring to a second one

    One other thing I just learned (and it makes sense when you hear the explanation) - when you are working with slices in pandas DataFrames, both the start and end values are inclusive. The reason is that you can use slices with string (column header) values so it is clearer when you are selecting...
  18. hanginthere

    Python Change values in one list by referring to a second one

    Actually, range(num) evaluates from 0 to num-1 as you can see if you execute list(range(5)), so do not subtract 1 in the statement. Perhaps you should test to make sure the two lists are actually the same length.
  19. hanginthere

    Python Python

    Try insert = 'inserted string' newstr = LOINCDATA.replace('\n', '\n' + insert + '\n')[:-len(insert)-1]
  20. hanginthere

    Greetings

    I strongly disagree about the "automating tasks" comment. I have developed several full blown applications using Python/wxPython. I wrote a Sudoku tool that is quite useful for solving those puzzles. It doesn't do any of the thinking. I just provides a GUI where, instead of repeatedly...
Back
Top Bottom