题目:

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. BUUCTF-[极客大挑战 2019]PHP 1

    打开题目,我们就看到这个猫,先是用鼠标晃了晃,还跟着我的光标摇脑袋.我是来做题的.前端工程师肯定也对这个下功夫了. 有一个良好的备份网站的习惯很好啊,我们首先根据题目的提示,用dirsearch扫目录 ...

  2. .NET Core使用FluentEmail发送邮件

    前言 在实际的项目开发中,我们会遇到许多需要通过程序发送邮件的场景,比如异常报警.消息.进度通知等等.一般情况下我们使用原生的SmtpClient类库居多,它能满足我们绝大多数场景.但是使用起来不够简 ...

  3. 多测师讲解自动化测试 _接口面试题(001)_高级讲师肖sir

    1.为什么要做接口测试(必要性)1.可以发现很多在页面上操作发现不了的bug2.检查系统的异常处理能力3.检查系统的安全性.稳定性4.前端随便变,接口测好了,后端不用变5.可以测试并发情况,一个账号, ...

  4. go内建方法 append copy delete

    package mainimport "fmt"func main() { testAppend() testCopy() testDelete()}func testAppend ...

  5. lumen中间件 Middleware

    app/http 下新建 TestMiddleware.php <?php namespace App\Http\Middleware; use Closure; class TestMiddl ...

  6. FreeRTOS链表实现

    直接上源码分析 void vListInitialise( List_t * const pxList ){ pxList->pxIndex = ( ListItem_t * ) &( ...

  7. 第十四章 nginx代理配置

    一.nginx代理 1.常见模式 1.常见模式:1)正向代理2)反向代理​2.区别1)区别在于形式上服务的"对象"不一样2)正向代理代理的对象是客户端,为客户端服务3)反向代理代理 ...

  8. IntelliJ IDEA 15款 神级超级牛逼插件推荐(超赞,谁用谁知道)

    满满的都是干货  所有插件都是在 ctrl+alt+s 里的plugins 里进行搜索安装 1.CodeGlance 代码迷你缩放图插件 2. Codota 代码提示工具,扫描你的代码后,根据你的敲击 ...

  9. MySQL数据库基础-3

    SQL语言 结构化的查询云烟 有国际标准. 非常容易学习的,关注数据本身,类似于shell SQL解释器 命令行效率比较高 应用编程接口 ODBC:Open Database Connectivity ...

  10. Vue3: 如何以 Vite 创建,以 Vue Router, Vuex, Ant Design 开始应用

    本文代码: https://github.com/ikuokuo/start-vue3 在线演示: https://ikuokuo.github.io/start-vue3/ Vite 创建 Vue ...