About 868,000 results
Open links in new tab
  1. python - How do I put a variable’s value inside a string (interpolate ...

    See for example How to use variables in SQL statement in Python? for proper techniques. If you just want to print (output) the string, you can prepare it this way first, or if you don't need the …

  2. Python 2.7 getting user input and manipulating as string without ...

    We can use the raw_input() function in Python 2 and the input() function in Python 3. By default the input function takes an input in string format. For other data type you have to cast the user …

  3. python - Letter Count on a string - Stack Overflow

    Python newb here. I m trying to count the number of letter "a"s in a given string. Code is below. It keeps returning 1 instead 3 in string "banana". Any input appreciated. def count_letters(word,...

  4. python - Creating if/else statements dependent on user input

    I'm trying to create a simple script that will will ask a question to which the user will input an answer (Or a prompt with selectable answers could appear?), and the program would output a …

  5. python - How to get multiline input from the user - Stack Overflow

    In Python 3.x the raw_input() of Python 2.x has been replaced by input() function. However in both the cases you cannot input multi-line strings, for that purpose you would need to get input from …

  6. How to define default value if empty user input in Python?

    Here I have to set the default value if the user will enter the value from the keyboard. Here is the code that user can enter value: input = int(raw_input("Enter the inputs : ")) Here the value wi...

  7. How can I check if string input is a number? - Stack Overflow

    This question is similar to: How do I check if a string represents a number (float or int)?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the …

  8. If statement for strings in python? - Stack Overflow

    answer = raw_input("Is the information correct? Enter Y for yes or N for no") input() evaluates whatever is entered as a Python expression, raw_input() returns a string. Edit: That is only true …

  9. How to define a function to take a string as input in Python 3

    Feb 17, 2017 · 1 As long as you document this properly, the requirement that a user pass a string to the function input should not cause concern or issues. This is standard in all Python …

  10. python - How can I read inputs as numbers? - Stack Overflow

    Dec 8, 2013 · Python 2.x There were two functions to get user input, called input and raw_input. The difference between them is, raw_input doesn't evaluate the data and returns as it is, in …