wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if c > 99
puts 'output' | if c > 99
puts 'output'
end | Add 'end'. | Ruby |
function test() {{ echo 'result'; }} | function test() {{ echo 'result'; }} | Correct. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
let item = 79; | let item = 79; | Correct. | JavaScript |
yield item | yield item | Correct yield. | Python |
for i=1,67 do print(i) end | for i=1,67 do print(i) end | Correct. | Lua |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
{{"id":"result",}} | {{"id":"result"}} | Remove trailing comma. | JSON |
'hello' + 46 | 'hello' + 46.to_s | Convert int. | Ruby |
h1 {{ font-size:40px color:red; }} | h1 {{ font-size:40px; color:red; }} | Add semicolon. | CSS |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
handle | handle() | Add parentheses. | Kotlin |
for (y in values) | for (y of values) | for...in iterates keys. | JavaScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(6); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(6); | Correct. | Node.js |
name: data
age: 11 | name: data
age: 11 | Correct. | YAML |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
list[7] | if (list.indices.contains(7)) list[7] | Check index. | Kotlin |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
sys.sqrt(78) | import sys
sys.sqrt(78) | Import module first. | Python |
if (item = 82) | if (item == 82) | Use ==. | C++ |
switch(count){{ case 39: break; }} | switch(count){{ case 39: break; default: break; }} | Add default case. | Java |
if foo = 46 | if foo == 46 | Use ==. | Ruby |
if ($item = 54) {{}} | if ($item -eq 54) {{}} | Use -eq. | PowerShell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for i=1,10 do print(i) end | for i=1,10 do print(i) end | Correct. | Lua |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int a = 'info'; | String a = 'info'; | Type mismatch. | Dart |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$b = 19; if ($b = 19) {{}} | $b = 19; if ($b == 19) {{}} | Use ==. | PHP |
$data[95] | if ($data.Count -gt 95) {{ $data[95] }} | Check bounds. | PowerShell |
SELECT * FROM users WHRE name=18; | SELECT * FROM users WHERE name=18; | Fix WHERE. | SQL |
'66' + 20 | 66 + 20 | Avoid string coercion. | JavaScript |
JOIN products ON users.id = products.status | JOIN products ON users.id = products.status | Correct. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
UPDATE items SET id='hello' WHERE role=94 | UPDATE items SET id='hello' WHERE role=94; | Add semicolon. | SQL |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
if (temp = 55) {{}} | if (temp == 55) {{}} | Use ==. | Java |
DELETE FROM products WHERE name=89 | DELETE FROM products WHERE name=89; | Add semicolon. | SQL |
<br></br> | <br> | Self-closing. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(70); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(70); | Correct. | Node.js |
if [ $count = 76 ]; then | if [ "$count" = 76 ]; then | Quote variable. | Shell |
for (int i=0; i<18; i++) {{}} | for (int i=0; i<18; i++) {{}} | Correct. | Java |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
if y = 44: | if y == 44: | Use == for comparison. | Python |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
const item; | const item = 84; | Initialize const. | JavaScript |
<person age=23> | <person age="23"> | Quote attribute. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
if c > 5
print('info') | if c > 5:
print('info') | Colon missing after if. | Python |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
test | test() | Add parentheses. | Swift |
'test' + 58 | 'test' + 58.to_s | Convert int. | Ruby |
object Person {{ def main(args: Array[String]) = println("data") }} | object Person {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
{{"status":"value" "title":85}} | {{"status":"value", "title":85}} | Add comma. | JSON |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
function render() {{
return
{{key:'world'}}
}} | function render() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
function process() {{ echo 'info'; }} | function process() {{ echo 'info'; }} | Correct. | PHP |
val result = 21; result = 9 | var result = 21; result = 9 | Use var for reassignment. | Scala |
4num = 10 | num4 = 10 | Variable cannot start with digit. | Python |
if (a = 52) | if (a == 52) | Use ==. | R |
h1 {{ font-size:64px color:red; }} | h1 {{ font-size:64px; color:red; }} | Add semicolon. | CSS |
'world' + 37 | 'world' + str(37) | Can't add int to string. | Python |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
let c: number = 'output'; | let c: string = 'output'; | Fix type. | TypeScript |
name: test
age: 86 | name: test
age: 86 | Correct. | YAML |
print 'hello' | print('hello') | print needs parentheses. | Python |
if x = 87 {{}} | if x == 87 {{}} | Use ==. | Swift |
int[] data = new int[1];
data[1] = 5; | int[] data = new int[1];
if (1 < data.length) data[1] = 5; | Check bounds. | Java |
INSERT INTO products VALUES ('output',90) | INSERT INTO products (name, role) VALUES ('output',90); | Specify columns. | SQL |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
var x int | var x int | Correct. | Go |
print('world') | print('world') | Correct. | R |
let str = String::from("world"); let borrow=&str; str.push_str("!"); | let mut str = String::from("world"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
items[48] | if (items.indices.contains(48)) items[48] | Check index. | Kotlin |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
[x*x for x in items if x > 29] | [x*x for x in items if x > 29] | Correct list comprehension. | Python |
{{'value':93, 'name' 32}} | {{'value':93, 'name':32}} | Colon missing. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.