题目:

Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).

Examples:

solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false

解题办法:

def solution(string, ending):
# your code here...
if ending == '':
return True
else:
a = string[::-1][:len(ending)][::-1]
if a == ending:
return True
else:
return False

最佳解题办法:

def solution(string, ending):
return string.endswith(ending)

知识点:

1、string.endswith(str):使用endswith可以判断是否以某个字符串结尾

【Kata Daily 190916】String end with?(字母结尾)的更多相关文章

  1. java string,需要进行首字母大写改写

    java string,需要进行首字母大写改写,网上大家的思路基本一致,就是将首字母截取,转化成大写然后再串上后面的,类似如下代码 //首字母大写     public static String c ...

  2. 【Kata Daily 190903】String incrementer(字符串增量器)

    原题: Your job is to write a function which increments a string, to create a new string. If the string ...

  3. 【Kata Daily 190917】Numericals of a String(字符出现的次数)

    题目: You are given an input string. For each symbol in the string if it's the first character occuren ...

  4. 【Kata Daily 190912】Alphabetical Addition(字母相加)

    题目: Your task is to add up letters to one letter. The function will be given a variable amount of ar ...

  5. C#查找以某个字母开头另一字母结尾的字符串

    using System; using System.Text.RegularExpressions; namespace ConsoleApplication1 { class Program { ...

  6. 【leetcode80】Reverse Vowels of a String(元音字母倒叙)

    题目描述: 写一个函数,实现输入一个字符串,然后把其中的元音字母倒叙 注意 元音字母包含大小写,元音字母有五个a,e,i,o,u 原文描述: Write a function that takes a ...

  7. 791. Custom Sort String字符串保持字母一样,位置可以变

    [抄题]: S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S wa ...

  8. C++ string 是否以‘\0’结尾 讨论

    转载https://blog.csdn.net/qq_31930499/article/details/80374310 之前在某篇文章中看到,C语言字符串是以’\0’结尾的,但是C++string类 ...

  9. 【Kata Daily 190929】Password Hashes(密码哈希)

    题目: When you sign up for an account somewhere, some websites do not actually store your password in ...

随机推荐

  1. 使用 PL/SQL Developer 导入 .sql 文件

    操作系统:Windows 10 x64 PL/SQL Developer Version 12.0.7.1837 (64 bit) 01.226959 第一节:下载 Oracle Database X ...

  2. JavaScript打印给定区间年份的闰年

    要求: 用户输入需要判断的年份区间,开始年份和结束年份,输出该区间内所有的闰年. 代码实现: function isRunYear(year) { // 是闰年返回true,否则返回false var ...

  3. 用C写一个简单的推箱子游戏(二)

    下面接着上一篇随笔<用C写一个简单的推箱子游戏(一)>来写 tuidong()函数是用来判断游戏人物前方情况的函数,是推箱子游戏中非常重要的一个函数,下面从它开始继续介绍推箱子的小程序怎么 ...

  4. 分析如何直接绕过超时代VPY视频播放器的播放密码

    声明:仅技术交流和学习! 前言: 你有没试过在网上下载一套视频,因网盘限速整整开机下载好几晚,下完后打开发现加密了,又找不到卖家注册.心里是几万只草泥马飞奔啊. 于是不甘心和好奇下,偿试自己破解. 目 ...

  5. sql ROW_NUMBER() 排序函数

    1.使用row_number()函数进行编号:如 1 select email,customerID, ROW_NUMBER() over(order by psd) as rows from QT_ ...

  6. fiddler 实用小技巧

    1.添加查看响应时间

  7. COMET —— 常识Transformer用于自动知识图构建

    <COMET:Commonsense Transformers for Automatic Knowledge Graph Construction> 论文地址 论文源码 任务 目的层面 ...

  8. TCMalloc 内存分配原理简析

    一.TCMalloc TCMalloc简介 为啥要介绍 TCMalloc? 因为golang的内存分配算法绝大部分都是来自 TCMalloc,golang只改动了其中的一小部分.所以要理解golang ...

  9. build设计模式

    又叫生成器模式 public class MainActivity extends AppCompatActivity { TextView textView; Button button; prot ...

  10. origin把点图和线图放在一起

    首先分别做好点图和线图在两个graph中,然后选中其中一副图(点图或者线图),然后按下图选择: 如果有多个图,可以在弹出窗口中选择多个sheet.