{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### String Comparisons\n", "\n", "We will examine now the concept of comparisons among strings and introduce a few comparison operators. \n", "\n", "#### Equality comparison\n", "\n", "Let's first examine how we can check if two strings are identical. For this comparison, we need the equality operator `==`.\n", "\n", "Let's see how equality comparisons work in Python:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "str1 = \"hello\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(str1 == \"hello\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(str1 == \"Hello\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that **capitalization matters** when comparsing strings in Python. If we want to make the comparison case-insensitive we typically first convert both sides of the equality to the same case:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(str1.lower() == \"Hello\".lower())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The opposite operator for equality is the inequality operator: `!=`. For example:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "email1 = \"panos@nyu.edu\"\n", "email2 = \"peter@nyu.edu\"\n", "print(\"Are the emails different?\", email1 != email2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Ordering Strings\n", "\n", "String also allow for inequality comparisons. When we compare strings, the string that is \"smaller\" is the one that is coming first in the dictionary. Let's see an example: " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "name1 = \"Abraham\"\n", "name2 = \"Bill\"\n", "\n", "# Abraham is lexicographically before Bill\n", "print(name1 < name2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "name1 = \"Panos\"\n", "name2 = \"Bill\"\n", "\n", "# Panos is lexicographically after Bill\n", "print(name1 < name2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice though the following, where the capitalization of `Bill` changes:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "name1 = \"Panos\"\n", "name2 = \"bill\"\n", "\n", "# Panos is lexicographically before bill\n", "print(name1 < name2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What causes this is the fact that the order is not simply the order in which we would encounter words in the dictionary. Technically, strings are ordered based on the order of the characters in the ASCII (or Unicode) table. Here is the ASCII table:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, if we have the string below, and we try to sort them, take a look at the order:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Space, followed by numbers, followed by uppercase, followed by lowercase\n", "sorted([\"Bill\", \" ZZ TOP!!! \", \"HAHA\", \"lol\", \"LOL!\", \"ZZZZZ\", \"zzzzz\", \"123\", \"345\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Example of string comparison\n", "# See ASCII table at http://www.asciitable.com/ for character order (FYI)\n", "\n", "name1 = \"Abe\"\n", "name2 = \"Bill\"\n", "\n", "# Abe is lexicographically before Bill\n", "print(name1 < name2)\n", "\n", "name1 = \"abe\"\n", "name2 = \"Bill\"\n", "# However 'abe' is lexicographically after Bill (which starts with an uppercase letter)\n", "print(name1 < name2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Finding text within string variables\n", "\n", "#### `in` operator\n", "\n", "\n", "+ The `in` operator, `needle in haystack`: reports if the string `needle` appears in the string `haystack`\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, string \"New York\" appears within \"New York University\", so the following operator returns `True`:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"New York\" in \"New York University\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "But, unlike reality, \"New York University\" is not in \"New York\" :-)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"New York University\" in \"New York\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "#### `find` function\n", "\n", "* The `find` function, `haystack.find(needle)`: searches `haystack` for `needle`, prints the position of the first occurrence, indexed from 0; returns -1 if not found.\n", "\n", "For example:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "word = \"Python is the word. And on and on and on and on...\"\n", "position = word.find(\"on\") # The 'on' appears at the end of 'Python'\n", "print(position)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(\"The first time that we see the string on is at position\", word.find(\"on\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we are looking to find additional appearances of the string, then we can add a second parameter in the `find` function, specifying that we are only interested in matches after the position specificed by the parameter." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "first_appearance = word.find(\"on\")\n", "second_appearance = word.find(\"on\", first_appearance + 1)\n", "print(\"The second time that we see the string on is at position\", second_appearance)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Exercise\n", "\n", "Consider the string `billgates@microsoft.com`. Write code that finds the username of the email address and the domain of the email address. You will need to use the .find() command, and also use your knowledge of indexing and slicing for this exercise. Hint: You will need to search for the `@` character using find, and then use the result to get the parts of the string before and after the `@` character. (Do not worry if this seems tedious, this is mainly for practice; later on, we will see how to do this in an easier way.)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### `count` function\n", "\n", "+ `str_1.count(str_2)`: counts the number of occurrences of one string in another." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "word = \"Python is the word. And on and on and on and on...\"\n", "lookfor = \"on\"\n", "count = word.count(lookfor)\n", "print(\"We see the string '\", lookfor, \"' that many times: \", count)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "word = \"Python is the word. And on and on and on and on...\"\n", "lookfor = \"Python\"\n", "count = word.count(lookfor)\n", "print(\"We see the string '\", lookfor, \"' that many times: \", count)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Of course, notice that if capitalization is different, the matches will not \"count\"." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "word = \"Python is the word. And on and on and on and on...\"\n", "lookfor = \"PYTHON\"\n", "count = word.count(lookfor)\n", "print(\"We see the string '\", lookfor, \"' that many times: \", count)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Exercise\n", "\n", "Convert the code above so that it works in a case-insensitive manner. Use the `lower()` or `upper()` command." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Exercise\n", "\n", "Consider the news article from [Washington Post](https://www.washingtonpost.com/news/powerpost/paloma/daily-202/2016/09/13/daily-202-clinton-hindered-by-enthusiasm-gap-in-pennsylvania/57d76c9bcd249a37b9882e15/), which is given below, and stored in the string variable `article`.\n", "\n", "* Count how many times the word `Clinton` appears in the article. .\n", "* Count how many times the word `Trump` appears in the article. \n", "* Now sum up the occurences of `Clinton` and `Trump` and display the percentage of coverage for each of the two strings. (For example, if Clinton appears 2 times and Trump 3 times, then Clinton is 40% and Trump is 60%.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "flake8-noqa-cell-E501" ] }, "outputs": [], "source": [ "article = \"\"\"\n", "THE BIG IDEA:\n", "PITTSBURGH—Hillary Clinton will carry Pennsylvania if she can just get the Democratic base to show up, but that’s easier said than done.\n", "African Americans are lukewarm compared to four and eight years ago, leaders of the community say, and distaste for Donald Trump is not enough to drive them to the polls. Many supporters of Bernie Sanders, who lost the state’s Democratic primary this spring by 12 points, say they might not vote at all.\n", "-- Trying to re-activate the coalition that allowed him to carry the state twice, Barack Obama will travel to Philadelphia today for a big downtown rally on Clinton’s behalf. Elizabeth Warren spoke to college students at Penn last Friday, and Sanders is coming to Carnegie Mellon this Friday. Bill Clinton spoke to a predominantly black audience here last week.\n", "-- While Hillary maintains a lead, and is favored to ultimately carry the state, everyone acknowledges that the race has tightened here over the past month even more than it has nationally. A Quinnipiac poll last week put Clinton up 5 points, down from 10 points a few weeks before. A Franklin and Marshall College poll published the week before had her up 7 points, but the percentage viewing her favorably had dropped to 38 percent from 47 percent in July.\n", "-- Many analysts believe turnout will be lower in 2016 than in 2012 or 2008. That would help Trump and Republican Sen. Pat Toomey. Less important than the percentage of support Clinton pulls among young people and minorities is the number of total votes she gets from these constituencies. In the past two presidential elections, for example, Obama won in Philly proper by more than half a million votes – creating an almost insurmountable advantage that Romney’s strength elsewhere could not match.\n", "In 2012, as a point of reference, 5.8 million ballots were cast. “I don’t know how we get there,” said James Lee, who runs Susquehanna Polling and Research, a Republican-aligned firm that does survey work for several media outlets. “The closer you get to 5 million, the better for Trump. We know who is not turning out: the college students and the minorities. That’s polling 101.”\n", "Trump speaks last night at U.S. Cellular Center in Asheville, North Carolina. (Brian Blanco/Getty Images)\n", "-- Anecdotally, there are many reasons for Democrats to worry about a lack of enthusiasm.\n", "Take Jared Ault of Pittsburgh, who supported Sanders in the primary and has not decided what to do in November. He said two of his brothers are certain they will not vote. Neither will his aunt, and five of his friends at work have told him they plan to stay home.\n", "“It’s probably the most difficult election we’ve had in recent years, probably since the 1950s. I really think we’re going to see the lowest turnout in my lifetime,” Ault said. “Both are just so divisive. Clinton has so many skeletons in her closet, and I honestly believe Trump is a sociopath. … Hillary has her hands in the pockets of a lot of the major corporations, and that’s why they support her. I’m just thoroughly disgusted by the way this election has gone.”\n", "The 30-year-old banking consultant, with a two-year-old in a stroller and another baby on the way, cast his first vote for George W. Bush but has steadily become more liberal since then. He was one of a few Democratic-leaning folks I met at a Pirates baseball game who are torn about whether to get behind Clinton, support someone like Jill Stein or Gary Johnson or just not bother with figuring it out. Ultimately, Ault allowed, he might vote for Clinton if he concluded that Trump would become president if he did not. But someone needs to convince him\n", "John Fetterman announces his candidacy for U.S. Senate last September. (Keith Srakocic/AP)\n", "-- David Plouffe, who managed Obama’s 2008 campaign, has repeatedly said that Pennsylvania is not a true battleground and advises Democrats against spending too much there.\n", "“I don’t share David Plouffe’s supreme confidence that Pennsylvania is guaranteed to be blue,” responds Braddock Mayor John Fetterman, a Bernie supporter who ran unsuccessfully in the Democratic primary for Senate this year. “Without a doubt, it is one that’s going to be close. The Democrats have to continue to make a case. If Democrats keep their head down and stay focused, we can. It’s not a sure thing, and we can’t take any vote for granted. That’s for sure.”\n", "Fetterman is hosting the Sanders rally in Pittsburgh this Friday, and he’s been campaigning for Katie McGinty, who beat him in the Democratic primary and now faces Toomey. “In my case, I tell people, ‘Look I ran as the most progressive voice in my campaign and I came up short. Democrats have to come together,’” he said in an interview. “Once again, I remain convinced that the biggest driving force toward unity is the prospect of Donald Trump.”\n", "-- After Trump telegraphed that his theory of the case hinged on Pennsylvania, Democrats siphoned additional resources to the state. Operatives say the nuts-and-bolts of their field program in 2016 is much stronger than in 2012, especially with the top-tier Senate race.\n", "“I’m really not the eternal optimist. I’m the guy that urges caution. And I do today,” said T.J. Rooney, a former chairman of the state Democratic Party. “But I do so with an appreciation of how much better the ground operation is here this cycle than it’s ever been. What gives me comfort, or solace, is the understanding that all the things that can possibly be done to communicate with these men and women are being done.”\n", "He thinks Obama coming to Philly today will make a difference. “He reminds people of what’s at stake and what we need to do,” said Rooney. “You can do events with this president, and you can see almost overnight the tangible result of his visit.”\n", "-- The Keystone State is already drawing vastly more attention and money than four years ago, when Mitt Romney stayed away until the 11th hour and then lost by 5.5 points.\n", "George W. Bush campaigns in the Rust Belt in 2004. (Stephen Jaffe/AFP/Getty Images)\n", "-- But a generation of GOP operatives has experienced the quadrennial temptations of the Pennsylvania Siren Song, and many feel like Trump’s big play is a fool’s errand. George H.W. Bush in 1988 was the last Republican to carry the state. George W. Bush tried very hard and still lost Pennsylvania by 144,000 votes in 2004 – the closest margin since then.\n", "“Even when Republicans get close, they never really get over the finish line,” said Lee, who runs the GOP-aligned polling firm. “The problem is that in the polling four years ago, when Obama had a slight lead or Romney was within the margin of error, most of the undecided were Democrats. People usually break toward their party in the final days.”\n", "-- When you do the math, Trump has a narrow path to victory:\n", "He’s over-performing Romney in rural areas but under-performing him in the suburbs, and there are more voters in the latter. “The four suburban Philadelphia counties are the lynchpin to carrying the state,” said Terry Madonna, who conducts the Franklin & Marshall College Poll. Obama carried all four in 2008 and got three of them in 2012. Right now, Trump is trailing in the double digits in these areas and would lose all four.\n", "Hillary campaigns in West Philadelphia last month. (Jessica Kourkounis/Getty Images)\n", "Democrats, with a registration advantage of 919,000, also simply have more potential voters. Steven Yaccino and Sasha Issenberg dive into the voter file for a numbers-heavy piece on Bloomberg this morning: “(The party) can count on a base of nearly 1.69 million votes, and—thanks in part to overwhelming support from African-Americans in Philadelphia—another 1.37 million less-reliable voters who can be mobilized through get-out-the-vote work. If Clinton manages to turn out all of the Democratic base and get out the vote targets, she would have more than 3 million votes in her pocket without having to win over a single persuadable voter. And Trump could run a perfect ground game, miraculously turn out all his Republican targets, win every expected persuadable vote cast—projected to be around 187,000—and still lose.”\n", "“That means that the difference between a battleground and a blowout in Pennsylvania is whether Trump can peel off Democrats,” Steven and Sasha add. “The most obvious targets are the some 300,000 white blue-collar men living in areas most affected by shuttered plants. If, say, Trump were able to lure this entire group, it would be enough to flip Democrats’ 556,000-voter lead to an ever-so-slight 21,000 Republican advantage.”\n", "-- Analyzing voter registration data, the Philadelphia Inquirer argues that The Trump Effect is being overstated and that he’s not drawing new as many new voters into the process as his campaign claims: “Some 129,000 new Pennsylvania voters have joined the GOP since November. But Democrats, aided by a heated primary between Clinton and Sanders, have added 172,000 … In a separate tally, a sizable 39,000 more voters converted to Republican than switched to Democrat this year -- part of a trend of party defections that began in 1988. … Of the Republican voters (in Bucks County) who skipped at least the last three presidential elections, only 3 percent showed up for this year's primary.”\n", "-- But Pennsylvania is a big prize, and Trump is coming back this week. If he can find a way to get the state’s 20 electoral votes, several additional routes to 270 open. He could afford to lose another, smaller battleground, including Virginia (13), North Carolina (15), Nevada (6), New Hampshire (4) or Iowa (6).\n", "Welcome to the Daily 202, PowerPost's morning newsletter.\n", "With contributions from Elise Viebeck (@eliseviebeck).\n", "Sign up to receive the newsletter.\n", "WHILE YOU WERE SLEEPING:\n", "-- U.S. News's 2017 college rankings posted at midnight. “Among this year’s novelties, the University of Chicago placed third on the national university list, tied with Yale, just behind Harvard and up from ninth as recently as six years ago,” Nick Anderson flags. “Wellesley, previously fourth among liberal arts colleges, moved up to third, switching places with Swarthmore.” See the full list here.\n", "-- The NCAA announced it will pull all 2016-17 championship events out of North Carolina to retaliate against the state’s so-called “bathroom bill.\" A spokesman for the Republican Party responded: “I wish the NCAA was this concerned about the women who were raped at Baylor.\" (Des Bieler)\n", "-- The Clinton campaign said it will release additional medical records this week, seeking to put to rest lingering concerns over her health after Sunday’s incident, and Hillary herself called into CNN last night to talk about her pneumonia. “I didn’t think it was going to be that big a deal,\" she said. “Obviously I should have gotten some rest sooner,\" she told Anderson Cooper. \"It's just the kind of thing that if it happens to you and you're a busy, active person, you keep moving forward.” (Abby Phillip and Anne Gearan)\n", "Scuffles break out at Trump's Asheville rally Embed Share Play Video3:07\n", "Pushing, grabbing, punching and obscene gesturing broke out between Donald Trump supporters and protesters at the Republican presidential nominee's rally in Asheville, N.C., on Sept. 12. (Jenny Starrs/The Washington Post)\n", "-- Trump accused Clinton of running \"a hate-filled campaign” during a rally in North Carolina, riling up an already-tense crowd. \"While my opponent slams you as deplorable and irredeemable, I call you hard-working American patriots who love your country,\" Trump told supporters in Asheville. “But the atmosphere quickly grew tense as protesters repeatedly interrupted his speech,” Sean Sullivan reports: \"At one point, a man took a fighting stance and then pushed and grabbed male protesters and swatted at a female protester.\" While protesters were taken out of the rally, a supporter – who later began shouting at a woman in a hijab to “get out” – was permitted to stay.\n", "-- Clinton is responding to Trump's attacks over \"deplorables\" with a new ad that will run on national cable. It juxtaposes clips of the GOP nominee disparaging various \"losers\" and groups -- including women, Mexicans, the disabled, John McCain, the Khans -- against footage of him saying: \"You can't lead this nation if you have such a low opinion of its citizens.\" Watch the Clinton ad here. Watch Trump's ad on this topic, released yesterday morning, here.\n", "Farmworkers celebrate in Sacramento. (Rich Pedroncelli/AP)\n", "-- Big win for labor: Jerry Brown last night signed historic legislation that will gradually add hundreds of thousands of California farmworkers to the ranks of those who are paid overtime. “Leaders of the United Farm Workers of America, which sponsored the overtime bill, called Brown’s decision a victory in a nearly 80-year quest to establish broad rights and protections for farm laborers. But the move shocked the agricultural community, which lobbied heavily against its provisions,” the Los Angeles Times reports. “Brown’s signature followed a pair of intense showdowns on the floor of the state Assembly, where a similar proposal died in June a few votes short of the majority it needed to pass.”\n", "Ryan Lochte performs on \"Dancing With the Stars.\" (Eric McCandless/AP)\n", "-- Ryan Lochte’s “Dancing With the Stars” debut was interrupted after two male protesters stormed the stage. Witnesses said the men tried to knock down the embattled Olympic swimmer before they were escorted offstage by security. (Emily Yahr)\n", "Syrian men carrying babies make their way through the rubble of destroyed buildings following a air strike on the rebel-held Salihin neighborhood of Aleppo. (Ameer Alhalbi/AFP/Getty Images)\n", "GET SMART FAST:??\n", "A U.S.- and Russian-backed ceasefire agreement that went into effect Monday was almost immediately violated, diluting hopes for an imminent halt to the relentless violence that has raged for five years. Residents of the besieged rebel portion of Aleppo said that Syrian government helicopters dropped barrel bombs on one neighborhood and that loyalist forces were shelling a route intended to be used for the delivery of humanitarian aid. (Liz Sly and Karen DeYoung)\n", "North Korea’s nuclear program is directed at the United States, a close adviser to Kim Jong Un said after last week’s atomic test, according to a Japanese lawmaker who just returned from Pyongyang. (Anna Fifield)\n", "President Obama is expected to veto a bill approved by Congress that would allow families of the victims of the 9/11 terror attacks to sue Saudi Arabia. Obama is worried about such suits hurting a key U.S. alliance. Congressional leaders will likely pursue an override vote. (David Nakamura, Karoun Demirjian and Mike DeBonis)\n", "A federal judge announced that he is unlikely to hear arguments in a lawsuit challenging a proof-of-citizenship requirement in a mail-in federal voter registration form used by Kansas, Alabama and Georgia until an appeals court panel that looked at the matter issues its written opinion. The move by U.S. District Judge Richard J. Leon of Washington means it is unlikely that the requirement will be enforced for November’s elections. (Spencer S. Hsu)\n", "The FDA is weighing a crackdown on stem-cell clinics across the United States. (Laurie McGinley)\n", "Shameful: The Department of Veterans Affairs stopped sharing data on the quality of care at its facilities this summer, breaking a 2014 law that helps veterans make informed decisions. In a separate move, the VA also took down its own site that provided side-by-side quality comparisons of its hospitals – leaving the site completely blank. (USA Today)\n", "Occidental College is launching an investigation after vandals destroyed a 9/11 memorial on campus – ripping out 3,000 flags from the ground and displaying posters and fliers that shamed the victims. (Cleve R. Wootson Jr.)\n", "New York police are investigating a potential hate crime after the blouse of a traditionally-dressed Muslim woman was set on fire. The woman was not badly hurt in the attack, which occurred on the eve of 9/11. (New York Daily News)\n", "Police charged a man with attempting to destroy a 9/11 memorial wreath at Arlington National Cemetery. The guy was intoxicated. (Dana Hedgpeth)\n", "The Defense Department announced the death of a top ISIS leader, confirming the success of a drone strike launched two weeks ago. The Pentagon took extra precautions before announcing the militant’s death because it was falsely reported last year. (Thomas Gibbons-Neff)\n", "Federal Reserve governors are leaning towards waiting until late in the year to raise short-term interest rates, feeling little sense of urgency as unemployment rates remain steady and inflation holds below their 2 percent target. (Wall Street Journal lead story)\n", "Iran threatened to shoot down two U.S. Navy planes flying close to Iranian territory in the Persian Gulf over the weekend, Fox News reports. It is the latest in a series of confrontations, with Iranian fast-boats harassing U.S. warships “on at least five occasions” in August.\n", "The deadliest fire in Memphis in a century ripped through a family home, killing nine and leaving just one survivor. Investigators believe the family may have been trapped by bars on the windows, and the blaze blocked their only means of escape. (Cleve R. Wootson Jr.)\n", "Former British Prime Minister David Cameron will step down from Parliament. Brexit ended his political career. (AP)\n", "Four Paralympic athletes ran the 1,500-meter race faster than anyone at the Rio Olympics – all besting the times of U.S. gold-medal winner Matthew Centrowitz. The class in which they competed is among those for the visually impaired, Des Bieler reports, and none of the athletes had access to blades or any other devices to help them compete.\n", "The U.S. Naval Academy announced it will update its instructor screening process after allowing the employment of a Marine Corps officer investigating for an improper sexual relationship with a female midshipman. (John Woodrow Cox)\n", "Prince George’s County prosecutors dropped the bad-check charge against Walter E. Fauntroy, putting an end to a years-long legal mess that prompted the 83-year-old (D.C.'s former delegate to Congress) to flee the country. The onetime civil rights leader paid back his $20,000 debt last week. (Lynh Bui)\n", "Former California Assemblyman Tom Calderon was sentenced to a year in federal custody for laundering bribes taken by his brother, a former state senator. He will be sentenced next week. (LA Times)\n", "The Canadian federal judge who found himself in hot water for asking a rape victim during a trial why she couldn't keep her knees together said he now regrets those comments. (Kristine Guerra)\n", "-- PowerPost's second installment of its Women in Power series just posted this morning with an inside look at how women have operated inside the traditionally male-dominated West Wing. Our White House bureau chief, Juliet Eilperin, reveala a practice known as \"amplification,\" which female staffers used during President Obama's first term to get heard: \"When a woman made a key point, other women would repeat it, giving credit to its author. This forced the men in the room to recognize the contribution – and denied them the chance to claim the idea as their own ... 'We just started doing it, and made a purpose of doing it. It was an everyday thing,' said one former Obama aide who requested anonymity to speak frankly.\" Getting into important meetings and face-time with the president are the coins of the realm in any administration, Juliet reports: Before becoming national security adviser, for example, Susan E. \"Rice said, she had to push to get into key gatherings. 'It’s not pleasant to have to appeal to a man to say, ‘Include me in that meeting,'” she said.\"\n", "More from the Women in Washington series:\n", "Matt Zapotosky interviews Attorney General Loretta Lynch about how race and gender have affected her career.L\n", "Elise Viebeck tells us how fundraising is critical to female lawmakers' success an interviews Rep. Karen Bass (D-Calif.) about how male politicians are more emotional than women.\n", "Kelsey Snell reports on how hard it is -- still -- to recruit women to run for federal office. She also interviews longtime Ways and Means staff director Janice Mays about her four decades on the Hill.\n", "Ben Terris talks to Rep. Elise Stefanik about what its like to be the youngest woman in the House\n", "Elise gets some words of wisdom from GOP operative Juleanna Glover about how conservative women can #NeverTrump.\n", "Hillary waves after leaving Chelsea's apartment in New York on Sunday. (AP/Andrew Harnik)\n", "THE DAILY HILLARY:\n", "-- It's not the pneumonia. It's the way they handled it that's causing problems. “There’s a reason that we have had a long tradition in this country of individual candidates disclosing information about their health to the American public before the election,\" White House Press Secretary Joshua Earnest said, noting that Obama did so as a candidate, and has continued to do so as president, to underscore the point.\"\n", "-- Clinton’s decision to “power through” set in motion perhaps the most damaging cascade of events for her general election so far, Philip Rucker and Anne Gearan report. “Had Clinton heeded her doctor’s advice, she would not have gone to a glitzy fundraiser Friday night where she let her guard down and inartfully talked about Trump’s supporters, nor would she have been spotted collapsing Sunday morning.\"\n", "-- Many of Clinton’s own staff did not know she was sick, and her campaign spokesmen refusing to specify how many aides knew about her illness. It also was unclear whether Clinton’s running mate, Sen. Tim Kaine, was in the know. \n", "-- “The real issue is chronic dehydration,\" according to Politico’s Glenn Thrush, \"exacerbated by her lung problem and Clinton’s reluctance to drink water, which has become a source of tension with her staff. 'She won’t drink water, and you try telling Hillary Clinton she has to drink water,” said a person in her orbit.\"\n", "-- Sen. Chuck Schumer (D-N.Y.) said yesterday that he too was diagnosed with pneumonia a few weeks ago, but it has already cleared up.\n", "-- As they always do with with the Clintons, Republicans are overplaying their hand with unhinged conspiracy theories:\n", "A co-chair of the “Veterans for Trump” coalition said he believes Clinton has Parkinson’s disease: “They may have admitted HRC has pneumonia, but that’s not WHY she has pneumonia,” Daniel Tamburello, a New Hampshire State representative and former Trump delegate, wrote on his Facebook page. “I believe she has pneumonia caused by Parkinson’s disease.” (Buzzfeed)\n", "Rep. Gary Palmer said he has “serious doubts” as to whether Clinton has pneumonia: “I mean … just my observation, if it were pneumonia, I would’ve thought they would’ve come out and said that very early on,” the Alabama lawmaker said. Palmer went on to reference Clinton’s recent coughing spells: “They’ve tried to attribute the cough to bronchitis, they’ve tried to attribute it to pneumonia, but I sat in the Benghazi hearing for three hours,” he said. “And she sat there and coughed her way through that. You know, again, you just look at the pattern and it just begs the question, are we being lied to again?” (Buzzfeed)\n", "And Trump adviser Ben Carson called for Clinton to release results of a “specialized MRI,” continuing to make vague speculations about her overall health. “The fact that the security detail assisting her as she clumsily attempted to enter her vehicle … did not appear surprised as if dealing with something new,” Carson said of Clinton’s 9/11 departure. “[It] … makes one wonder if such awkward moments are something they have become accustomed to.” Carson’s comments come as a break with the Trump campaign, who has avoided discussion about Clinton’s health. (Buzzfeed)\n", "-- Bennet Omalu, the forensic pathologist best known for his discovery of chronic traumatic brain encephalopathy in the brains of deceased football players, suggested that Clinton’s campaign be checked for “possible poisons” after her collapse: “I must [advise] the Clinton campaign to perform toxicologic analysis of Ms. Clinton’s blood,” he said on Twitter. “It is possible she is being poisoned.” The well-credentialed expert, whose story was told in the movie “Concussion,” went on to insist he “does not trust” Putin or Trump in the 2016 election. (Cindy Boren)\n", "-- “The hidden history of presidential disease, sickness and secrecy,” by Joel Achenbach and Lillian Cunningham: “In his second term as president, Dwight Eisenhower looked like an old man. He’d had a serious heart attack in 1955, requiring extensive hospitalization. In contrast to his seeming senescence, his successor, John F. Kennedy, seemed vibrant and flamboyant. The reality was that …. Kennedy wasn't actually that vigorous, and indeed was secretly afflicted by serious medical problems, including Addison’s disease, that his aides concealed from the public. The history of the presidency includes a running thread of illness and incapacity, much of it hidden from the public out of political calculation. A stroke incapacitated Woodrow Wilson in 1919, for example, but the public had no inkling until many months later. And when Grover Cleveland needed surgery in 1893 to remove a cancerous tumor in his mouth, he did it secretly, on a friend's yacht cruising through Long Island Sound. The desire to keep their physical condition secret led many American presidents to avoid the best doctors, says historian Matthew Algeo.”\n", "-- Both Clinton and Trump owe voters more specifics on their health, The Post’s editorial board writes. “Sen. John McCain, who was 71 when he ran for president … released nearly 1,200 pages of medical records. He did not do this to feed pure voyeurism. He did it so that voters could evaluate their comfort with the health of a septuagenarian applying for the toughest job in the world — in which there are no sick days and a slip of the tongue can become an international incident. Neither Ms. Clinton, who is 68, nor Mr. Trump have come close to this level of disclosure. Both need to do better.”\n", "-- “It seems unlikely that [Trump] has familiarized himself with Susan Sontag’s ‘Illness as Metaphor,’ in which Sontag argued that illness is often perceived as a result of weak character traits,” NYT’s Susan Dominus writes. “But for weeks, Trump seemed to be working off some kind of Sontag-inspired playbook. Clinton was not just lacking in the physical stamina required to fight ISIS, he said, ‘but the mental stamina’; his team often spoke of her as ‘frail.’ In turning illness into a personality flaw, a dangerous side effect of femaleness, Trump most likely made it all the more difficult for Clinton to acknowledge straightaway whatever health issue was in fact troubling her, whenever it kicked in in earnest. … In the narrative of this particular, strange election cycle, Clinton’s moment of evident illness will surely come to symbolize something. What that is, exactly, depends on how crudely, how truthfully, campaigners on both sides manipulate or manage a subject that is both intimately personal and yet significant for the public.”\n", "-- Bill Clinton will take his wife's place place at two Beverley Hill fundraisers today, headlining an event at the home of Seth MacFarlane -- which will feature a performance by Lionel Richie -- and a dinner hosted at the home of of Diane von Furstenberg and Barry Diller. (Matea Gold)\n", "-- The former president told Charlie Rose that his wife has gotten sick like this before and said she does not have a more “serious” illness. “Well if it is, it’s a mystery to me and all of her doctors,” he said, “because frequently—well not frequently, rarely—but on more than one occasion, over the last many, many years, the same sort of thing happened to her when she got severely dehydrated.” She had “two and a half hard days” on the campaign trail before the incident, he added, saying he is “glad” she made the decision to take a break.\n", "Bill also defended the Clinton Foundation’s relationship with the State Department, saying he’s “unaware” of any instance in which a Clinton Foundation donor ever received special treatment from his wife when she was secretary of state. The foundation, he said, has been “as transparent as we can be.” Clinton also differentiated between long-standing government relationships and “pay-to-play” favors leveraged for a few minutes of facetime with his wife: “Now, if you think nobody should ever call somebody they know and say, ‘Well, so-and-so would like a meeting’—that’s just the way the national government works, so I can’t say anything about that,” he said. “But I can say to the best of my knowledge … that the people they accused or implied gave money to the foundation just so they could have some in with Hillary did not do that. That’s simply not true.”\n", "Trump scolds Clinton for ‘deplorables’ comment Embed Share Play Video0:56\n", "Speaking in Asheville, N.C., Sept. 12, Republican presidential nominee Donald Trump said his Democratic opponent Hillary Clinton “talks about people like they are objects, not human beings,” following her comments on Trump’s supporters. (The Washington Post)\n", "THE DAILY DONALD:\n", "-- Pot calls kettle black: Trump slammed Clinton’s “basket of deplorables” comment as \"the single biggest mistake of the political season\" and demanded she apologize to anyone she might have offended. From Jenna Johnson: \"Personally, when I heard it, I thought that it was not something that was within the realm of possible, that she would have said it,” he said on Fox News. \"And she actually did, and she even really doubled up, because it was said with such anger, such unbelievable anger. And I think this is the biggest mistake of the political season.\"\n", "-- Clinton has expressed regret for saying that \"HALF\" of Trump's supporters were in the \"basket of deplorables\" but not for the underlying point. But as Trump’s campaign hones in on the comment, conservatives and progressives are growing further apart in their analysis of what was even said. From Dave Weigel: “In a conference call organized by the RNC, Rep. Marsha Blackburn (R-Tenn.) insisted that Clinton was referring to some percentage of veterans. Bill Kristol, an anti-Trump conservative, also suggested that Clinton may have been insulting the troops. The argument, which is expected to be advanced by [Trump] … is not about the specifics of the gaffe. It is about the fact that Clinton could consider any voter ‘deplorable,’ and whether doing so reveals a snobbiness that is unbecoming (or, to use the buzzword of 2016, ‘disqualifying’) from a presidential candidate.”\n", "-- Mike Pence refused to call former KKK Grand Wizard David Duke “deplorable” in a CNN interview -- highlighting the difficulty of taking a hardline stance against Clinton's remarks. When asked by host Wolf Blitzer if Duke and other white nationalists would fit into the “deplorable category,” Pence declined to respond directly. “I’m not really sure why the media keeps dropping David Duke’s name,” Pence replied. “He has denounced David Duke repeatedly.” “So you call him a deplorable?” Blizter pressed.“ No, I’m not in the name-calling business, Wolf,” Pence said. “You know me better than that.” (Philip Bump)\n", "-- Making it worse: Duke then praised Pence for his remarks, saying he is “pleased” that the GOP vice presidential nominee declined to call him deplorable. “It’s good to see an individual like Pence and others start to reject this absolute controlled media,” Duke said. “The truth is the Republican Party is big tent. I served in the Republican caucus. I was in the Republican caucus in the legislature. I had a perfect Republican voting record. It’s ridiculous that they attack me because of my involvement in that nonviolent Klan four decades ago.” (Buzzfeed)\n", "-- “The media’s criticism of Clinton’s claim has been matched in vehemence only by their allergy to exploring it,” Ta-Nehisi Coates complains in The Atlantic. “It is easy enough to look into Clinton’s claim and verify it or falsify it. … Consider the following: Had polling showed that relatively few Trump supporters believe black people are lazy and criminally-inclined, if only a tiny minority of Trump supporters believed that Muslims should be banned from the country … would journalists decline to point this out as they excoriated her? Of course not. But the case against Clinton’s 'basket of deplorables' is a triumph of style over substance, of clamorous white grievance over knowable facts. The safe space for the act of being white endures today. This weekend, the media … saw it challenged and—not for the first time—organized to preserve it. For speaking a truth, backed up by data, Clinton was accused of promoting bigotry. No. The true crime was endangering white consciousness.”\n", "Janet Yellen, right, attends a Jackson Hole economic summit in Wyoming last month. (David Paul Morris/Bloomberg)\n", "-- Trump accused the Federal Reserve of keeping interest rates low to help bolster Obama’s political legacy, saying in a CNBC interview that Fed Chair Janet Yellen should be “ashamed of herself.” “She’s obviously political and doing what Obama wants her to do, and I know that’s not supposed to be the way it is,” Trump said. Doubting whether rates would change while Obama remains in office, Trump said: \"[Obama] wants to go out. He wants to play golf for the rest of this life. And he doesn't care what's going to happen after January.\" Trump’s remarks come as a shift from his previous comments this spring, in which he praised low interest rates as “the best thing we have going for us.” (Ylan Q. Mui)\n", "-- James Woolsey, one of Bill Clinton’s CIA directors, joined the Trump campaign as a senior adviser on national security, defense and intelligence. Woolsey, who also advised John McCain in 2008, said he favors the Republican nominee’s plan to remove the sequester caps on defense spending. (Politico)\n", "-- Robert Zoellick, who served as a top official in both Bush administrations and as president of the World Bank, slammed Trump as a “dangerous man” with a dark side: “I’ve seen the presidency up close,” Zoellick said during a podcast hosted by Republican strategist Mike Murphy. “Trump is a dangerous man. I would not want that man with his finger on the triggers.” In the podcast, Zoellick said Trump “has no sense of dignity … and there’s a dark side to him, too.” (Buzzfeed)\n", "-- Trump's presidential transition operation is quietly building a series of policy teams tasked with mapping out his agenda, Politico’s Andrew Restuccia reports. “The transition operation [chaired by Chris Christie] is setting up policy teams focused on taxes, financial services, veterans, national security, energy and even building a border wall between the United States and Mexico … Christie huddled behind closed doors last week with GOP lobbyists from the financial services and energy sector, and the transition staff is expected to balloon in size over the next week as Christie brings more policy advisers on board.” Each policy team, currently in the process of vetting and conducting background checks on potential staffers, will reportedly be tasked with developing a series of \"action items\" for Day 1, Day 100 and Day 200 of a potential Trump administration.\n", "-- The Post’s David A. Fahrenthold looks more deeply at the five cases in which the Trump Foundation reported making a donation that does not seem to exist. “Five times, the Trump Foundation's tax filings described giving a specific amount of money to a specific charity — in some cases, even including the recipient's address. But when The Post called, the charities listed said the tax filings appeared wrong. They'd never received anything from Trump or his foundation.”\n", "-- Trump’s campaign attempted to push back on reports about his stingy charitable giving, with both spokeswoman Hope Hicks and Mike Pence saying he has given “tens of millions” to charity over his lifetime, David adds. But they refuse to offer any details or proof to back up the claim. “In all, The Post has identified less than $9 million in gifts to charity from Trump's pocket over his lifetime, including the $5.3 million he gave to his foundation before the last gift in 2008. In addition, Trump's foundation has taken in about $9 million from other donors, and given away most of it. Last year, the Trump campaign also put out a detailed list of what it said was $102 million in charitable giving from Trump over five years. But a close look by The Post found that not a single one of the gifts listed was actually a donation of Trump's own money.”\n", "-- LinkedIn co-founder Reid Hoffman said he will donate up to $5 million to veterans if Trump releases his tax returns before the final presidential debate. A Crowdpac campaign led by Marine veteran Peter Kiernan is also trying to incentivize Trump to release his returns. (Business Insider)\n", "Demonstrators gather in front of the newly opened Trump International Hotel. (Chip Somodevilla/Getty)\n", "-- Trump came to D.C. for the opening of his new luxury hotel. \"When Trump International Hotel Washington, D.C. hosted its soft opening Monday, it capped the transformation of a century-old post office building into one of Washington’s most expensive and ostentatious new hotels — and a monument to Trump,\" Jonathan O'Connell and Drew Harwell report. \"But its main draw, the gilded name out front, might also be its biggest obstacle. … Indeed, the hotel reflects many of the contradictions at the heart of Trump’s campaign: a 1 percenter fortress built alongside a populist campaign by a self-described billionaire, whose blue-collar rallygoers couldn’t afford a spoon of wine at his newest high-class masterwork. While Trump was shouting across middle America that Mexicans were drug-smuggling rapists, Hispanic men were building his luxury hotel for him on one of the national capital’s ritziest blocks. What began as merely a prominent real estate project has morphed into a political landmark, where polarizing ties to the blustery mogul could influence its business through November and beyond.\" \n", "-- Rooms at the Trump International Hotel are going for more than $700 a night. (Petula Dvorak)\n", "-- Trump posed for a photo with the staff:\n", "View image on Twitter\n", "View image on Twitter\n", " Follow\n", " Donald J. Trump ? @realDonaldTrump\n", "Stopped by @TrumpDC to thank all of the tremendous men & women for their hard work!\n", "11:51 AM - 12 Sep 2016\n", " 8,209 8,209 Retweets 27,509 27,509 likes\n", "THE BATTLEGROUNDS:\n", "-- “Worried Republicans are pouring resources into North Carolina,” by Sean Sullivan: Republicans are increasingly nervous about Trump and Pat McCrory losing the state and dragging down Sen. Richard Burr with them. \"More than a quarter of the 392 field staffers the [RNC] recently added nationwide have been assigned to North Carolina … [The Koch-backed] Americans for Prosperity … recently decided to shift its resources in the state to help Burr and go after his Democratic challenger.\"\n", "-- Morning Consult just posted a new Senator Approval Rankings survey, using more than 70,000 online interviews to determine how constituents feel about their home-state lawmakers. Some highlights:\n", "Mitch McConnell remains the least popular senator among home-state constituents (with 51 percent disapproval). Harry Reid is the third-least popular senator, with a 43 percent disapproval rating.\n", "Bernie Sanders is the most popular senator. (His approval rating in Vermont is 87 percent.)\n", "Susan Collins, who might run for governor of Maine in 2018, is the second most popular senator back home (69 percent approval). But her approval has fallen 10 points since she declined to endorse Trump earlier this year.\n", "Meanwhile, vulnerable senators continue to struggle: Pat Toomey saw a NINE point drop in his approval rating in Pennsylvania. Rob Portman’s approval has declined by four points in Ohio since the last Consult poll.\n", "The most vulnerable Republican up for re-election – Mark Kirk – now has more home-state voters disapproving of him than approving of him (38 percent vs. 35 percent.)\n", "Freshman Gary Peters is the most unknown: 38 percent of Michiganders do not know enough about him to offer an opinion, more than the number who approve (35) or disapprove (27). (See the list of approval numbers for all 100 senators here.)\n", "-- Evan Bayh's lead in Indiana continues to dwindle, according to a Howey Politics/WTHR survey. Bayh now holds just a four-point advantage over Republican candidate Todd Young in the state, 44 to 40, down from his double-digit lead in earlier surveys. George W. Bush campaigned and raised money with Young yesterday.\n", "-- Joe Garcia told supporters in Miami that Hillary \"is under no illusions that you want to have sex with her, or that she's going to seduce you.\" From the Miami Herald: Why the former Democratic congressman, running to win back his old seat, went there is unclear. Garcia’s remarks were secretly captured as he spoke informally at a Key West campaign office Saturday, praising Clinton as an “extremely, exceedingly competent” leader “similar to Lyndon Johnson.” \"Lyndon Johnson wasn't a particularly charming man, wasn't a particularly nice man: He would ask you nice, and then when you didn't do it, he made you do it,\" Garcia said. \"And Hillary is under no illusions that you want to have sex with her, or that she's going to seduce you, or out-think you.\" Garcia later defended his comments in a statement to the Herald, saying they speak to Clinton’s focus “on getting things done,” and “not on the gender stereotypes and biases women in public life are frequently subjected to.”\n", "Heavy flooding in North Korea (AFP Photo/Unicef DPRK/Murat Sahin)\n", "WAPO HIGHLIGHTS:\n", "-- “North Korea defied the world with a nuclear test. Now it seeks aid for a flood disaster,” by Anna Fifield: “Floods that devastated North Korea last month are turning out to be worse than initially feared, with more than 100,000 people left homeless, according to aid workers who visited the area last week. That puts Pyongyang in the inconvenient position of having to turn to the international community for help — at the same time North Korea is facing global condemnation after its nuclear test last week.” “The people there are in a very desperate situation,” said one emergency responder. “… At least 140,000 people are in urgent need of assistance, the [U.N. Office for the Coordination of Humanitarian Affairs] said in a statement, including an estimated 100,000 people who have been displaced. Water supplies to about 600,000 people have been cut.” One responder asked donor nations to remember that the flood has hurt regular people in North Korea: “These are people who are doing the best they can,” he said. “They’re just normal, everyday people.”\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Calculate the number of times that Clinton appears in the text" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Calculate the number of times that Trump appears in the text" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Compute the percentage for clinton" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Compute the percentage for Trump" ] }, { "cell_type": "markdown", "metadata": { "solution2": "hidden", "solution2_first": true }, "source": [ "#### Solution" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "solution2": "hidden" }, "outputs": [], "source": [ "# Calculate the number of times that Clinton appears in the text\n", "clinton = article.count(\"Clinton\")\n", "print(clinton)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "solution2": "hidden" }, "outputs": [], "source": [ "# Calculate the number of times that Trump appears in the text\n", "trump = article.count(\"Trump\")\n", "print(trump)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "solution2": "hidden" }, "outputs": [], "source": [ "# Compute the percetage for Clinton (vs total Clinton+Trump)\n", "perc_clinton = 100 * clinton / (clinton + trump)\n", "print(perc_clinton)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "solution2": "hidden" }, "outputs": [], "source": [ "# Compute the percetage for Trump (vs total Clinton+Trump)\n", "perc_trump = 100 * trump / (clinton + trump)\n", "print(perc_trump)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "solution2": "hidden" }, "outputs": [], "source": [ "# All together\n", "clinton = article.count(\"Clinton\")\n", "trump = article.count(\"Trump\")\n", "perc_clinton = 100 * clinton / (clinton + trump)\n", "perc_clinton = round(perc_clinton, 2)\n", "perc_trump = 100 * trump / (clinton + trump)\n", "perc_trump = round(perc_trump, 2)\n", "print(\"Clinton appears\", clinton, \"times:\", perc_clinton, \"%\")\n", "print(\"Trump appears\", trump, \"times:\", perc_trump, \"%\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### `startswith` and `endswith` functions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we can also check if a particular string starts or ends with a another substring\n", "\n", "+ `haystack.startswith(needle)`: does a the haystack string start with the needle string?\n", "+ `haystack.endswith(needle)`: does a the haystack string end with the needle string?\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "name = \"New York University\"\n", "prefix = \"New York\"\n", "print(\"Does \", name, \" starts with\", prefix, \"?\")\n", "print(name.startswith(prefix))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "name = \"New York University\"\n", "prefix = \"University\"\n", "print(\"Does \", name, \" starts with\", prefix, \"?\")\n", "print(name.startswith(prefix))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "name = \"New York University\"\n", "suffix = \"University\"\n", "print(\"Does \", name, \" ends with\", suffix, \"?\")\n", "print(name.endswith(suffix))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "celltoolbar": "Tags", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.2" } }, "nbformat": 4, "nbformat_minor": 1 }