Advertisement
Carl123432

PythonTwitterLeassonEP5

Jan 18th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. # String's, we are going to learn more about strings.
  2. # In python you can use either '' or "" for a string, but let me show you error you can run into.
  3.  
  4. # hello = 'Hi this is carl's house' # you may notice that we cannot use a Apostrophe due to useing it to start the string.
  5. # One wat around it is to use quotation marks to start the string instead.
  6.  
  7. hello = "Hi this is carl's"
  8.  
  9. # Now to write a new line inside your string you use \n like so.
  10.  
  11. hello = "Hello there, today we are learning \n About strings in python"
  12.  
  13. # Or we can use tripple quotations which will read all new lines untill you close the string.
  14.  
  15. hello = """ Dear Carl,
  16. I hope you are find, i have just recived your letter.
  17. i will be booking my flight and returning home soon,
  18. i hope you get better by the time i arrive home.
  19. Your sincicly,
  20. Carl"""
  21.  
  22. # Now we can join strings togther like so,
  23.  
  24. hello = 'Hi im '
  25. name = 'Bob '
  26. how = 'How are you today? '
  27. sentence = hello+name+how
  28. print(sentence)
  29.  
  30. # Or we can use a comma on one line of a string.
  31.  
  32. sentence = 'Hi im', 'bob', 'How are you today?'
  33. print(sentence)
  34.  
  35. # But using the comma method created sentence into a list.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement