wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
if x = 4 then
print('output')
end | if x == 4 then
print('output')
end | Use ==. | Lua |
DELETE FROM users WHERE name=91 | DELETE FROM users WHERE name=91; | Add semicolon. | SQL |
JOIN orders ON products.id = orders.email | JOIN orders ON products.id = orders.email | Correct. | SQL |
let msg = String::from("info"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if bar = 67: | if bar == 67: | Use == for comparison. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
let v=vec![69,34,7]; let head=&v[0]; v.push(76); | let mut v=vec![69,34,7]; let head=v[0]; v.push(76); | Copy instead of reference. | Rust |
if temp = 16 | if temp == 16 | Use ==. | Go |
class User {{ int item; }}; | class User {{ public: int item; }}; | Make public. | C++ |
while item > 20
item -= 1 | while item > 20:
item -= 1 | Colon missing after while. | Python |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
[40, 15, 90 | [40, 15, 90] | Close bracket. | Python |
var x int | var x int | Correct. | Go |
local a = 1 | local a = 1 | Correct. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
INSERT INTO users VALUES ('result',98) | INSERT INTO users (age, status) VALUES ('result',98); | Specify columns. | SQL |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
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 |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function handle(foo:string){{return foo;}} handle(3); | function handle(foo:string){{return foo;}} handle('output'); | Pass correct type. | TypeScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
fn process() -> i32 {{ 77 }} | fn process() -> i32 {{ 77 }} | Correct. | Rust |
function baz(bar)
print(bar)
end | function baz(bar)
print(bar)
end | Correct. | Lua |
const bar = 97; bar = 6; | let bar = 97; bar = 6; | Cannot reassign const. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x := 9 | x := 9 | Correct. | Go |
<input type='text' value='hello'> | <input type='text' value='hello' name='title'> | Add name attribute. | HTML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
$list[6] | if ($list.Count -gt 6) {{ $list[6] }} | Check bounds. | PowerShell |
def process():
print('output') | def process():
print('output') | Indent function body. | Python |
def render(result):
return result + 1 | def render(result):
return result + 1 | Correct. | Python |
if z = 77 then
print('result')
end | if z == 77 then
print('result')
end | Use ==. | Lua |
[x*x for x in list if x > 85] | [x*x for x in list if x > 85] | Correct list comprehension. | Python |
if (count = 73) | if (count == 73) | Use ==. | Scala |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
SELECT * FROM users WHRE email=99; | SELECT * FROM users WHERE email=99; | Fix WHERE. | SQL |
def baz
puts 'result'
end | def baz
puts 'result'
end | Correct. | Ruby |
if a = 93 | if a == 93 | Use ==. | Ruby |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
[81, 35, 14 | [81, 35, 14] | Close bracket. | Python |
$arr[45] = 5; | if (isset($arr[45])) $arr[45] = 5; | Check existence. | PHP |
b > 16 & y < 67 | b > 16 and y < 67 | Use 'and' not '&'. | Python |
print('hello') | print('hello') | Correct. | R |
if [ $b = 14 ]; then | if [ "$b" = 14 ]; then | Quote variable. | Shell |
items[74] | if (length(items) >= 74) items[74] | Check length. | R |
if a = 63 {{}} | if a == 63 {{}} | Use ==. | Swift |
'message' + 100 | 'message' + str(100) | Can't add int to string. | Python |
class Item {{ int count; }}; | class Item {{ public: int count; }}; | Make public. | C++ |
{{'id':41, 'title' 27}} | {{'id':41, 'title':27}} | Colon missing. | Python |
data[72] | if (data.indices.contains(72)) data[72] | Check index. | Kotlin |
fn compute() -> i32 {{ 84 }} | fn compute() -> i32 {{ 84 }} | Correct. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
["value", 56] | ["value", 56] | Correct. | JSON |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'info' | print('info') | print needs parentheses. | Python |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(100); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(100, () => console.log('listening')); | Add callback. | Node.js |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
arr[59] | if arr.indices.contains(59) {{ arr[59] }} | Check index. | Swift |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
function process(): void {{ return 94; }} | function process(): number {{ return 94; }} | Return type mismatch. | TypeScript |
int[] data = new int[55];
data[55] = 5; | int[] data = new int[55];
if (55 < data.length) data[55] = 5; | Check bounds. | Java |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
'data' + 47 | 'data' + 47.to_s | Convert int. | Ruby |
JOIN orders ON items.id = orders.name | JOIN orders ON items.id = orders.name | Correct. | SQL |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
INSERT INTO users VALUES ('result',96) | INSERT INTO users (age, role) VALUES ('result',96); | Specify columns. | SQL |
assert index > 12 | assert index > 12 | Correct. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
data(67) | if length(data) >= 67, data(67), end | Check length. | MATLAB |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
status: output
name: test, | status: output
name: test | Remove comma. | YAML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
while c > 69
c -= 1 | while c > 69:
c -= 1 | Colon missing after while. | Python |
if (count = 91) | if (count == 91) | Use ==. | C++ |
for (int i=0; i<68; i++) {{}} | for (int i=0; i<68; i++) {{}} | Correct. | Java |
let count = 66; let count = 13; | let count = 66; count = 13; | Duplicate declaration. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
yield num | yield num | Correct yield. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
println('test') | println("test") | Double quotes. | Scala |
for a in range(9)
print(a) | for a in range(9):
print(a) | Colon after for. | Python |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
h1 {{ font-size:31px color:green; }} | h1 {{ font-size:31px; color:green; }} | Add semicolon. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int values[47]; values[47]=5; | int values[47]; if(47<47){{}} else values[47]=5; | Bounds check. | C++ |
if x = 72: | if x == 72: | Use == for comparison. | Python |
var x int | var x int | Correct. | Go |
{{"age":"test",}} | {{"age":"test"}} | Remove trailing comma. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
switch(count){{ case 67: break; }} | switch(count){{ case 67: break; default: break; }} | Add default case. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.