Python
1: Print Function
2: Escape Sequence
3: Comments
4: Escape Sequence as Normal Text
5: Print Emoji
6: Python as Calculator
7: Strings Concatenation
8: Input
9: int function
10: Variables
11: String Formatting
12: String Indexing
13: String Slicing
14: Step Argument
15: Some useful function and methods
16: Strip Method
17: Find and Replace method
2: Escape Sequence
3: Comments
4: Escape Sequence as Normal Text
5: Print Emoji
6: Python as Calculator
7: Strings Concatenation
8: Input
9: int function
10: Variables
11: String Formatting
12: String Indexing
13: String Slicing
14: Step Argument
15: Some useful function and methods
16: Strip Method
17: Find and Replace method
Chapter 8: Input
Using the input() function, we can take input from the user, store it in a variable, and use it for further programming.
Note: The input() function always takes input as a string.
name = input("Write your name: ")
Output: Write your name: (Enter your name here)
chapter = input("What is the chapter number: ") # take the input as a string
Output: What is the chapter number: (Enter the chapter number here)
Here, both inputs will prompt the user to enter a value.
In Python, we can also take multiple inputs in a single line using the .split() method.
name, chapter = input("Enter your name, age, and city (separated by comma): ").split(",")
Output: Enter your name, age, and city (separated by comma): (input one) , (input two) , (input three)