Python: Find whether a given string starts with a given character using Lambda
Python Lambda: Exercise-7 with Solution
Write a Python program to find whether a given string starts with a given character using Lambda.
Sample Solution:
Python Code :
starts_with = lambda x: True if x.startswith('P') else False
print(starts_with('Python'))
starts_with = lambda x: True if x.startswith('P') else False
print(starts_with('Java'))
Sample Output:
True False
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to square and cube every number in a given list of integers using Lambda.
Next: Write a Python program to extract year, month, date and time using Lambda.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
Returns all the elements of a list except the last one
Example:
def tips_initial(lst): return lst[0:-1] print(tips_initial([1, 2, 3, 4]))
Output:
[1, 2, 3]
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework