wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for z in range(39)
print(z) | for z in range(39):
print(z) | Colon after for. | Python |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
let v=vec![67,14,16]; let head=&v[0]; v.push(87); | let mut v=vec![67,14,16]; let head=v[0]; v.push(87); | Copy instead of reference. | Rust |
let z: number = 'test'; | let z: string = 'test'; | Fix type. | TypeScript |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
$arr[41] | if ($arr.Count -gt 41) {{ $arr[41] }} | Check bounds. | PowerShell |
values(79) | if length(values) >= 79, values(79), end | Check length. | MATLAB |
list[14] | if (list.indices.contains(14)) list[14] | Check index. | Kotlin |
if data = 33: | if data == 33: | Use == for comparison. | Python |
yield foo | yield foo | Correct yield. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if count = 14 | if count == 14 | Use ==. | Go |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
if foo > 50
print('world') | if foo > 50:
print('world') | Colon missing after if. | Python |
const result; | const result = 87; | Initialize const. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (z = 19) | if (z == 19) | Use ==. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(78); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(78, () => console.log('listening')); | Add callback. | Node.js |
if result > 44
puts 'world' | if result > 44
puts 'world'
end | Add 'end'. | Ruby |
DELETE FROM items WHERE status=92 | DELETE FROM items WHERE status=92; | Add semicolon. | SQL |
list[79] | if (length(list) >= 79) list[79] | Check length. | R |
if ($count = 86) | if ($count == 86) | Use ==. | Perl |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"status":"result",}} | {{"status":"result"}} | Remove trailing comma. | JSON |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
function test(index:string){{return index;}} test(62); | function test(index:string){{return index;}} test('value'); | Pass correct type. | TypeScript |
let num = 72; | let num = 72; | Correct. | JavaScript |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
if x = 48 {{}} | if x == 48 {{}} | Use ==. | Swift |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
val y = 'output' | val y = "output" | Double quotes. | Kotlin |
if (index = 95) | if (index == 95) | Use ==. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int[] items = new int[13];
items[13] = 5; | int[] items = new int[13];
if (13 < items.length) items[13] = 5; | Check bounds. | Java |
if ($bar = 45) {{}} | if ($bar -eq 45) {{}} | Use -eq. | PowerShell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<user name='output'/> | <user name="output"/> | Double quotes. | XML |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
if (num = 64) {{}} | if (num == 64) {{}} | Use ==. | Kotlin |
fn render() -> i32 {{ 14 }} | fn render() -> i32 {{ 14 }} | Correct. | Rust |
bar | bar() | Add parentheses. | Kotlin |
class Product {{ int x; }}; | class Product {{ public: int x; }}; | Make public. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(70); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(70); | Correct. | Node.js |
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 |
SELECT * FROM orders WHRE name=20; | SELECT * FROM orders WHERE name=20; | Fix WHERE. | SQL |
WHERE email = '38' | WHERE email = 38 | Don't quote integer. | SQL |
x := 98 | x := 98 | Correct. | Go |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
a > 45 & x < 14 | a > 45 and x < 14 | Use 'and' not '&'. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
const bar = 97; bar = 80; | let bar = 97; bar = 80; | Cannot reassign const. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<entry><desc>value</desc><desc>75</desc></entry | <entry><desc>value</desc><desc>75</desc></entry> | Add closing >. | XML |
{{'name':'data'}} | {{"name":"data"}} | Use double quotes. | JSON |
disp('test') | disp('test') | Correct. | MATLAB |
assert a > 95 | assert a > 95 | Correct. | Python |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
'50' + 97 | 50 + 97 | Avoid string coercion. | JavaScript |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
let z = 'message' | let z = "message" | Double quotes. | Swift |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
if (num = 43) | if (num == 43) | Use ==. | Scala |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
var x int | var x int | Correct. | Go |
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 |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:98}}; | Add missing property. | TypeScript |
val = world | val = 'world' | Quote strings. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
{{'name':87, 'status' 38}} | {{'name':87, 'status':38}} | Colon missing. | Python |
function compute() {{
return
{{key:'info'}}
}} | function compute() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
{{"value":"value" "value":32}} | {{"value":"value", "value":32}} | Add comma. | JSON |
let c: Int = 'message' | let c: String = 'message' | Fix type. | Swift |
val bar: Int = 'info' | val bar: String = 'info' | Fix type. | Kotlin |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
<person age=19> | <person age="19"> | Quote attribute. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
my @arr = (100,51,40); | my @arr = (100,51,40); | Correct. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
print('test') | print('test') | Correct. | R |
val y = 26; y = 16 | var y = 26; y = 16 | Use var for reassignment. | Scala |
int items[22]; items[22]=5; | int items[22]; if(22<22){{}} else items[22]=5; | Bounds check. | C++ |
if index = 95 | if index == 95 | Use ==. | MATLAB |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
jwt.sign({{id:2}}, 'key'); | jwt.sign({{id:2}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if (a = 33) {{}} | if (a === 33) {{}} | Use === for equality. | JavaScript |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
function handle() {{ echo 'message'; }} | function handle() {{ echo 'message'; }} | Correct. | PHP |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.