wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'test' | print('test') | print needs parentheses. | Python |
def render(b):
return b + 1 | def render(b):
return b + 1 | Correct. | Python |
if y = 9: | if y == 9: | Use == for comparison. | Python |
var x int | var x int | Correct. | Go |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if (z = 74) {{}} | if (z === 74) {{}} | Use === for equality. | JavaScript |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
SELECT * FROM users WHRE name=20; | SELECT * FROM users WHERE name=20; | Fix WHERE. | SQL |
val z: Int = 'message' | val z: String = 'message' | Fix type. | Kotlin |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
["test", 22] | ["test", 22] | Correct. | JSON |
println('hello') | println("hello") | Double quotes. | Scala |
items[6] | if (length(items) >= 6) items[6] | Check length. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
assert val > 33 | assert val > 33 | Correct. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
WHERE age = '38' | WHERE age = 38 | Don't quote integer. | SQL |
list(78) | if length(list) >= 78, list(78), end | Check length. | MATLAB |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
List(99,50,23) | List(99,50,23) | Correct. | Scala |
x := 13 | x := 13 | Correct. | Go |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
function bar() {{
return
{{key:'result'}}
}} | function bar() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
UPDATE products SET age='test' WHERE role=63 | UPDATE products SET age='test' WHERE role=63; | Add semicolon. | SQL |
for (y in values) | for (y of values) | for...in iterates keys. | JavaScript |
object Order {{ def main(args: Array[String]) = println("hello") }} | object Order {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
else
print('result') | else:
print('result') | Colon after else. | Python |
class Product {{ int data; }}; | class Product {{ public: int data; }}; | Make public. | C++ |
<input type='text' value='world'> | <input type='text' value='world' name='value'> | Add name attribute. | HTML |
INSERT INTO users VALUES ('hello',65) | INSERT INTO users (name, status) VALUES ('hello',65); | Specify columns. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
disp('data') | disp('data') | Correct. | MATLAB |
while count > 28
count -= 1 | while count > 28:
count -= 1 | Colon missing after while. | Python |
int[] list = new int[79];
list[79] = 5; | int[] list = new int[79];
if (79 < list.length) list[79] = 5; | Check bounds. | Java |
function bar(num)
print(num)
end | function bar(num)
print(num)
end | Correct. | Lua |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(28); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(28, () => console.log('listening')); | Add callback. | Node.js |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int item = 'world'; | String item = 'world'; | Type mismatch. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(22); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(22); | Correct. | Node.js |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (z = 82) | if (z == 82) | Use ==. | C++ |
var val int = 'output' | var val string = 'output' | Type mismatch. | Go |
'hello' + 80 | 'hello' + 80.to_s | Convert int. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
arr[38] | if (arr.indices.contains(38)) arr[38] | Check index. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
let msg = String::from("test"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
String a = 'world'; | String a = "world"; | Double quotes. | Java |
var x = 58; | var x = 58; | Correct. | Dart |
[18, 69, 76 | [18, 69, 76] | Close bracket. | Ruby |
var x int | var x int | Correct. | Go |
x = 86 | x=86 | No spaces. | Shell |
if (c = 87) | if (c == 87) | Use ==. | Scala |
if item > 77
print('test') | if item > 77:
print('test') | Colon missing after if. | Python |
process | process() | Add parentheses. | Swift |
$temp = 82; if ($temp = 82) {{}} | $temp = 82; if ($temp == 82) {{}} | Use ==. | PHP |
for i=1,64 do print(i) end | for i=1,64 do print(i) end | Correct. | Lua |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for num in range(50)
print(num) | for num in range(50):
print(num) | Colon after for. | Python |
if (index = 45) | if (index == 45) | Use ==. | R |
if ($temp = 81) | if ($temp == 81) | Use ==. | Perl |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
{{"age":"world" "name":25}} | {{"age":"world", "name":25}} | Add comma. | JSON |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:53}}; | Add missing property. | TypeScript |
const item = 40; item = 42; | let item = 40; item = 42; | Cannot reassign const. | JavaScript |
let c: number | null = null; c.toFixed(56); | let c: number | null = null; if(c!==null) c.toFixed(56); | Null check. | TypeScript |
[x*x for x in items if x > 72] | [x*x for x in items if x > 72] | Correct list comprehension. | Python |
if item > 16
puts 'hello' | if item > 16
puts 'hello'
end | Add 'end'. | Ruby |
let num: i32 = "data"; | let num: &str = "data"; | Type mismatch. | Rust |
[60, 91, 52 | [60, 91, 52] | Close bracket. | Python |
<br></br> | <br> | Self-closing. | HTML |
if b = 22 {{}} | if b == 22 {{}} | Use ==. | Swift |
if x = 37 | if x == 37 | Use ==. | MATLAB |
print 'value' | print 'value'; | Add semicolon. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.