Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Im using python crash course version 2
#1
i want to use \n \t in a variable and print


name = " JOHN "
print(name.lstrip())
print(name.rstrip())
print(name.strip())
print("\tname")
print("\nname")

it gives an error on this print("\tname")
print("\nname")

sorry i can´t find box parentice
ichabod801 wrote Sep-07-2019, 09:12 PM:
Square brackets are generally typed with the same keys as curly brackets, just without the shift key.
Quote
#2
What error is it giving you? Or is it just not printing what you expected? Perhaps you meant:

print('\t', name)
or

print(f'\t{name}')
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#3
(Sep-07-2019, 09:14 PM)ichabod801 Wrote: What error is it giving you? Or is it just not printing what you expected? Perhaps you meant:

print('\t', name)
or

print(f'\t{name}')




it print name istead of john
JOHN
JOHN
JOHN
name

name

so it ses name as a string i think and not as a variable
Quote
#4
Right. Things in quotes are strings, not variable names. You need to take them out of the quotes (my first example) or use a special string syntax so that they are recognized as variables (my second example).
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python version on Linux whois1230 5 246 Apr-10-2020, 07:12 PM
Last Post: buran
  Wrong pip3 python location or new Version 007fred50 1 319 Apr-02-2020, 02:36 PM
Last Post: philgoetz
  Error while trying to see Python version with "sys.executable" karkas 5 376 Feb-09-2020, 01:55 AM
Last Post: karkas
  update certbot's python version metulburr 0 626 Sep-19-2019, 11:51 AM
Last Post: metulburr
  Python 3 crash course james_newbie 6 692 Aug-25-2019, 08:23 PM
Last Post: snippsat
  Trouble importing modules on a new python version snackman_barry 2 491 Jul-12-2019, 11:15 AM
Last Post: snackman_barry
  [split] Using this Python version of text2pdf jonsnow1221 1 464 May-07-2019, 07:48 PM
Last Post: micseydel
  Using this Python version of text2pdf Pedroski55 1 559 Apr-15-2019, 08:12 AM
Last Post: Pedroski55
  can't install package web in version python 3.7 a21250450 1 590 Mar-29-2019, 11:28 AM
Last Post: Larz60+
  Python Version on Mac OSX Sparkstorm 5 688 Feb-06-2019, 10:32 AM
Last Post: Sparkstorm

Forum Jump:


Users browsing this thread: 1 Guest(s)