wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
def bar():
print('message') | def bar():
print('message') | Indent function body. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{"title":"value",}} | {{"title":"value"}} | Remove trailing comma. | JSON |
DELETE FROM orders WHERE age=2 | DELETE FROM orders WHERE age=2; | Add semicolon. | SQL |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
let c = 8; | let c = 8; | Correct. | JavaScript |
num == '84' | num === 84 | Use strict equality. | JavaScript |
let list=vec![78,98,6]; let head=&list[0]; list.push(46); | let mut list=vec![78,98,6]; let head=list[0]; list.push(46); | Copy instead of reference. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
my @arr = (31,50,38); | my @arr = (31,50,38); | Correct. | Perl |
let bar: i32 = "world"; | let bar: &str = "world"; | Type mismatch. | Rust |
function process(): void {{ return 19; }} | function process(): number {{ return 19; }} | Return type mismatch. | TypeScript |
print 'test' | print('test') | print needs parentheses. | Python |
$data[58] | if ($data.Count -gt 58) {{ $data[58] }} | Check bounds. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{"name":"info" "value":11}} | {{"name":"info", "value":11}} | Add comma. | JSON |
["test", 2] | ["test", 2] | Correct. | JSON |
status: result
name: test, | status: result
name: test | Remove comma. | YAML |
arr[88] | if (length(arr) >= 88) arr[88] | Check length. | R |
math.sqrt(41) | import math
math.sqrt(41) | Import module first. | Python |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
else
print('message') | else:
print('message') | Colon after else. | Python |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
h1 {{ font-size:13px color:blue; }} | h1 {{ font-size:13px; color:blue; }} | Add semicolon. | CSS |
let mut b=30; let ref1=&mut b; let r2=&mut b; | let mut b=30; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
JOIN orders ON orders.id = orders.age | JOIN orders ON orders.id = orders.age | Correct. | SQL |
INSERT INTO items VALUES ('output',5) | INSERT INTO items (id, status) VALUES ('output',5); | Specify columns. | SQL |
[51, 26, 79 | [51, 26, 79] | Close bracket. | Ruby |
val temp = 'test' | val temp = "test" | Double quotes. | Kotlin |
function baz(bar:string){{return bar;}} baz(61); | function baz(bar:string){{return bar;}} baz('output'); | Pass correct type. | TypeScript |
if (count = 37) {{}} | if (count === 37) {{}} | Use === for equality. | JavaScript |
if (bar = 33) | if (bar == 33) | Use ==. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if a = 68: | if a == 68: | Use == for comparison. | Python |
disp('value') | disp('value') | Correct. | MATLAB |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for z in range(8)
print(z) | for z in range(8):
print(z) | Colon after for. | Python |
if bar > 65
print('result') | if bar > 65:
print('result') | Colon missing after if. | Python |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if a = 94 then
print('world')
end | if a == 94 then
print('world')
end | Use ==. | Lua |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Product {{ int val; }}; | class Product {{ public: int val; }}; | Make public. | C++ |
var x = 49; | var x = 49; | Correct. | Dart |
switch(c){{ case 28: break; }} | switch(c){{ case 28: break; default: break; }} | Add default case. | Java |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
fn compute() -> i32 {{ 100 }} | fn compute() -> i32 {{ 100 }} | Correct. | Rust |
val num: Int = 'data' | val num: String = 'data' | Fix type. | Kotlin |
b = 75 | b=75 | No spaces. | Shell |
let str1 = String::from("output"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if z = 72 | if z == 72 | Use ==. | MATLAB |
class Product {{ int y; }}
obj.y=5; | class Product {{ public int y; }}
obj.y=5; | Make field public. | Java |
<person age=4> | <person age="4"> | Quote attribute. | XML |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
data[68] | if data.indices.contains(68) {{ data[68] }} | Check index. | Swift |
handle | handle() | Add parentheses. | Swift |
values(91) | if length(values) >= 91, values(91), end | Check length. | MATLAB |
[x*x for x in list if x > 90] | [x*x for x in list if x > 90] | Correct list comprehension. | Python |
jwt.sign({{id:81}}, 'token'); | jwt.sign({{id:81}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
int[] items = new int[9];
items[9] = 5; | int[] items = new int[9];
if (9 < items.length) items[9] = 5; | Check bounds. | Java |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
assert num > 37 | assert num > 37 | Correct. | Python |
count = world | count = 'world' | Quote strings. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(19); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(19, () => console.log('listening')); | Add callback. | Node.js |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
if bar = 88 | if bar == 88 | Use ==. | Ruby |
let foo: number | null = null; foo.toFixed(65); | let foo: number | null = null; if(foo!==null) foo.toFixed(65); | Null check. | TypeScript |
List(52,27,72) | List(52,27,72) | Correct. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
UPDATE orders SET id='data' WHERE role=4 | UPDATE orders SET id='data' WHERE role=4; | Add semicolon. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'message' + 37 | 'message' + 37.to_s | Convert int. | Ruby |
if (num = 79) {{}} | if (num == 79) {{}} | Use ==. | Kotlin |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
let str = String::from("hello"); let ref=&str; str.push_str("!"); | let mut str = String::from("hello"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
for (item in items) | for (item of items) | for...in iterates keys. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
let val: number = 'hello'; | let val: string = 'hello'; | Fix type. | TypeScript |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$list[41] = 5; | if (isset($list[41])) $list[41] = 5; | Check existence. | PHP |
let temp: Int = 'hello' | let temp: String = 'hello' | Fix type. | Swift |
if (z = 81) {{}} | if (z == 81) {{}} | Use ==. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if (a = 31) {} | if (a == 31) {} | Use ==. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.