Skip to content
murmot

Results for “python string array example program code site:discuss.python.org java”

  • discuss.python.org

    How to use f string format without changing content of string?

    Python documentation. string — Common string operations. Source code: Lib/string.py String constants: The constants defined in this module are: Custom String Formatting: The built-in string class provides the ability to do complex variable substitutions ...

  • discuss.python.org

    Accessing A Dictionary Item That is an Array - Python Help ...

    May 7, 2020 · Break it down step-by step: menu ['main'] returns the string ‘Main’; 'items' [0] returns the character 'i'; so the third step becomes 'Main' ['i'] which fails. Instead, you need: menu ['items'] to return the list; followed by indexing the n-th element of the list. Putting them together with the call to print gives us: ... which prints ...

  • discuss.python.org

    How to get null terminated strings from a buffer? - Python Help...

    Do you have a small example that shows what you can so far? Once you have ctypes returning the array of 260 word (520 bytes) buffer to python you can decode it with buf.decode(‘utf-16’) and then look for ‘\0’ in the unicode string. I would be tempted to use.

  • discuss.python.org

    Comparing values in an array - Python Help - Discussions on ...

    Sep 8, 2022 · Hi, I am looking to write a short code to compare values in an array. For example, I want to have a list of values in a text file and then have each value compared to all of the other values to find out which ones are within 8 of each other. Example: 8, 9, 20, 22, 40, 39. Answer would be that the group of 8 and 9 and 20 and 22 would be within 8 of each other. I have no real world programming ...

  • discuss.python.org

    How to check if a dictionary element is an array - Python ...

    Jul 19, 2024 · Hi, welcome to the Python forum. An fyi, please follow these formatting instructions when entering code for better visibility: Now, regarding your question, here is an example that hopefully helps you to understand the concept. Note that you do not need to explicitly define the icon string in brackets as per your query.

  • discuss.python.org

    Ports in an array - Python Help - Discussions on Python.org

    I even tried 443 and got for example: It is how to prompt the user, but it returns a string, not a number or array of numbers.In Python, strings are iterable things, and iteration gets you each character (as a 1-character string). So if you have code: ports = input("Enter ports to scan

  • discuss.python.org

    How to write a function that returns a simple string value

    Oct 11, 2022 · Help please. I have to write a simple function that returns a string. The string (in this example) is a city and a country e.g. London, England I have done some other exercises where I return a formatted name e.g. Bob Johnson, but I cannot get this one right Here is my codes so far: def city_country(city_name, country_name): """Return a string value of information about a city and country ...

  • discuss.python.org

    Add option to pre define size of list - Python Help - Discussions on...

    Java: int [] arr = new int[10] (Create a new array object of type int and size 10) Similarly, to achieve the same in python we have to use the following code. Python: arr: list[int] arr = [None]*10 To avoid this, we can implement a feature where we can define the size of list while declaration.

  • discuss.python.org

    Color a list or a string - Python Help - Discussions on ...

    Apr 2, 2023 · Is there a way to color a string or a list/tuple ? for example something that we can do is the following: `` It’s important to understand here that the colouring done here is completely out of Python’s hands. When you run the Python interpreter in a terminal window, the terminal itself is a separate program, and that is the program that is actually interpreting these special characters as ...

  • discuss.python.org

    Comparing Strings - Python Help - Discussions on Python.org

    Jul 11, 2023 · The condition already represents what we want. As it happens, Python allows us to express this view of the problem almost directly. We want to know whether all examples of a character (let’s call it c) are in letters_guessed, where we repeat the check for each of the c examples that is in secret_word. The corresponding Python code is in that ...