ブリブリ備忘録 おっ、python

HackerRankの問題とコメント(python3) 拙いですが...

2018-09-11から1日間の記事一覧

String Validators

・問題 Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc. str.isalnum() This method checks if all the characters of a string …

Find a string

・問題 In this challenge, the user enters a string and a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right, not from right to left. NOTE: Str…

Mutations

・問題 We have seen that lists are mutable (they can be changed), and tuples are immutable (they cannot be changed). Let's try to understand this with an example. You are given an immutable string, and you want to make changes to it. Examp…

What's Your Name?

・問題 You are given the firstname and lastname of a person on two different lines. Your task is to read them and print the following: Hello firstname lastname! You just delved into python. Input Format The first line contains the first na…

String Split and Join

・問題 In Python, a string can be split on a delimiter. Example: >>> a = "this is a string" >>> a = a.split(" ") # a is converted to a list of strings. >>> print a ['this', 'is', 'a', 'string'] Joining a string is simple: >>> a = "-".join(…

sWAP cASE

・問題 You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa. For Example: Www.HackerRank.com → wWW.hACKERrANK.COM Pythonist 2 → pYTHONIST 2 Input Format A …