wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
function render() {{ echo 'test'; }} | function render() {{ echo 'test'; }} | Correct. | PHP |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
const val; | const val = 41; | Initialize const. | JavaScript |
baz | baz() | Add parentheses. | Swift |
if (index = 1) | if (index == 1) | Use ==. | C++ |
print 'result' | print 'result'; | Add semicolon. | Perl |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(48); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(48); | Correct. | Node.js |
[58, 15, 50 | [58, 15, 50] | Close bracket. | Ruby |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
handle | handle() | Add parentheses. | Kotlin |
switch(y){{ case 3: break; }} | switch(y){{ case 3: break; default: break; }} | Add default case. | Java |
x := 94 | x := 94 | Correct. | Go |
my @arr = (92,86,15); | my @arr = (92,86,15); | Correct. | Perl |
if (item = 55) | if (item == 55) | Use ==. | R |
let result = 'message' | let result = "message" | Double quotes. | Swift |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{{'id':'test'}} | {{"id":"test"}} | Use double quotes. | JSON |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
{{"value":"world" "title":10}} | {{"value":"world", "title":10}} | Add comma. | JSON |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class Item {{ int result; }}; | class Item {{ public: int result; }}; | Make public. | C++ |
function test(b)
print(b)
end | function test(b)
print(b)
end | Correct. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
DELETE FROM orders WHERE status=73 | DELETE FROM orders WHERE status=73; | Add semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let mut result=80; let ref1=&mut result; let ref2=&mut result; | let mut result=80; {{ let ref1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<entry><age>test</age><desc>98</desc></entry | <entry><age>test</age><desc>98</desc></entry> | Add closing >. | XML |
if (index = 99) {} | if (index == 99) {} | Use ==. | Dart |
{{'age':15, 'name' 92}} | {{'age':15, 'name':92}} | Colon missing. | Python |
let val: number = 'result'; | let val: string = 'result'; | Fix type. | TypeScript |
if item = 9 | if item == 9 | Use ==. | MATLAB |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
print('data') | print('data') | Correct. | R |
["value", 19] | ["value", 19] | Correct. | JSON |
bar == '9' | bar === 9 | Use strict equality. | JavaScript |
def foo(val):
return val + 1 | def foo(val):
return val + 1 | Correct. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (c = 10) {{}} | if (c === 10) {{}} | Use === for equality. | JavaScript |
else
print('world') | else:
print('world') | Colon after else. | Python |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
if result = 62 {{}} | if result == 62 {{}} | Use ==. | Swift |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
h1 {{ font-size:27px color:green; }} | h1 {{ font-size:27px; color:green; }} | Add semicolon. | CSS |
int[] values = new int[49];
values[49] = 5; | int[] values = new int[49];
if (49 < values.length) values[49] = 5; | Check bounds. | Java |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
const foo = 39; foo = 37; | let foo = 39; foo = 37; | Cannot reassign const. | JavaScript |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
for (c in arr) | for (c of arr) | for...in iterates keys. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$list[91] = 5; | if (isset($list[91])) $list[91] = 5; | Check existence. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'result' + 72 | 'result' + 72.to_s | Convert int. | Ruby |
yield num | yield num | Correct yield. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let temp: number | null = null; temp.toFixed(12); | let temp: number | null = null; if(temp!==null) temp.toFixed(12); | Null check. | TypeScript |
INSERT INTO products VALUES ('info',72) | INSERT INTO products (id, status) VALUES ('info',72); | Specify columns. | SQL |
for x in range(33)
print(x) | for x in range(33):
print(x) | Colon after for. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
let msg = String::from("hello"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
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 |
let num = 50; | let num = 50; | Correct. | JavaScript |
let list=vec![18,7,17]; let first=&list[0]; list.push(72); | let mut list=vec![18,7,17]; let first=list[0]; list.push(72); | Copy instead of reference. | Rust |
let str1 = String::from("data"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if a = 26 | if a == 26 | Use ==. | Go |
if val = 76 | if val == 76 | Use ==. | Ruby |
result = 84 | result=84 | No spaces. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if temp = 93 then
print('message')
end | if temp == 93 then
print('message')
end | Use ==. | Lua |
arr[21] | if (arr.indices.contains(21)) arr[21] | Check index. | Kotlin |
if (temp = 25) {{}} | if (temp == 25) {{}} | Use ==. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(40); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(40, () => console.log('listening')); | Add callback. | Node.js |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
println('hello') | println("hello") | Double quotes. | Scala |
UPDATE items SET status='info' WHERE status=96 | UPDATE items SET status='info' WHERE status=96; | Add semicolon. | SQL |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
list[32] | if list.indices.contains(32) {{ list[32] }} | Check index. | Swift |
local b = 65 | local b = 65 | Correct. | Lua |
$data[90] | if ($data.Count -gt 90) {{ $data[90] }} | Check bounds. | PowerShell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<person age=38> | <person age="38"> | Quote attribute. | XML |
if bar > 45
puts 'test' | if bar > 45
puts 'test'
end | Add 'end'. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.