wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for x in range(39)
print(x) | for x in range(39):
print(x) | Colon after for. | Python |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
print 'value' | print 'value'; | Add semicolon. | Perl |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
[61, 60, 24 | [61, 60, 24] | Close bracket. | Python |
if temp = 4 | if temp == 4 | Use ==. | MATLAB |
let b: number = 'test'; | let b: string = 'test'; | Fix type. | TypeScript |
{{"status":"data" "title":87}} | {{"status":"data", "title":87}} | Add comma. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (count = 57) {{}} | if (count == 57) {{}} | Use ==. | Kotlin |
$index = 80; if ($index = 80) {{}} | $index = 80; if ($index == 80) {{}} | Use ==. | PHP |
items[78] | if (items.indices.contains(78)) items[78] | Check index. | Kotlin |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
if [ $item = 100 ]; then | if [ "$item" = 100 ]; then | Quote variable. | Shell |
int arr[59]; arr[59]=5; | int arr[59]; if(59<59){{}} else arr[59]=5; | Bounds check. | C++ |
DELETE FROM orders WHERE id=35 | DELETE FROM orders WHERE id=35; | Add semicolon. | SQL |
var x = 58; | var x = 58; | Correct. | Dart |
[37, 58, 5 | [37, 58, 5] | Close bracket. | Ruby |
let mut index=84; let r1=&mut index; let r2=&mut index; | let mut index=84; {{ let r1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let text1 = String::from("message"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
int bar = 'value'; | String bar = 'value'; | Type mismatch. | Dart |
let str = String::from("world"); let ref=&str; str.push_str("!"); | let mut str = String::from("world"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
let v=vec![95,79,17]; let head=&v[0]; v.push(58); | let mut v=vec![95,79,17]; let head=v[0]; v.push(58); | Copy instead of reference. | Rust |
{{'title':'info'}} | {{"title":"info"}} | Use double quotes. | JSON |
function foo(): void {{ return 2; }} | function foo(): number {{ return 2; }} | Return type mismatch. | TypeScript |
if (foo = 28) {{}} | if (foo === 28) {{}} | Use === for equality. | JavaScript |
object Order {{ def main(args: Array[String]) = println("output") }} | object Order {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
assert y > 31 | assert y > 31 | Correct. | Python |
INSERT INTO products VALUES ('hello',91) | INSERT INTO products (name, role) VALUES ('hello',91); | Specify columns. | SQL |
id: message
value: test, | id: message
value: test | Remove comma. | YAML |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(6); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(6); | Correct. | Node.js |
{{'age':48, 'id' 9}} | {{'age':48, 'id':9}} | Colon missing. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
x := 81 | x := 81 | Correct. | Go |
for (val in list) | for (val of list) | for...in iterates keys. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
function foo() {{
return
{{key:'value'}}
}} | function foo() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
SELECT * FROM items WHRE age=26; | SELECT * FROM items WHERE age=26; | Fix WHERE. | SQL |
fn baz() -> i32 {{ 4 }} | fn baz() -> i32 {{ 4 }} | Correct. | Rust |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<note><name>data</name><age>64</age></note | <note><name>data</name><age>64</age></note> | Add closing >. | XML |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
os.sqrt(20) | import os
os.sqrt(20) | Import module first. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(40); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(40, () => console.log('listening')); | Add callback. | Node.js |
disp('info') | disp('info') | Correct. | MATLAB |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
values[34] | if (length(values) >= 34) values[34] | Check length. | R |
items(19) | if length(items) >= 19, items(19), end | Check length. | MATLAB |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if z = 99 | if z == 99 | Use ==. | Ruby |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:43}}; | Add missing property. | TypeScript |
if result = 9 {{}} | if result == 9 {{}} | Use ==. | Swift |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
val c = 'message' | val c = "message" | Double quotes. | Kotlin |
let item = 'data' | let item = "data" | Double quotes. | Swift |
while num > 98
num -= 1 | while num > 98:
num -= 1 | Colon missing after while. | Python |
foo | foo() | Add parentheses. | Swift |
const x; | const x = 76; | Initialize const. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
int[] data = new int[75];
data[75] = 5; | int[] data = new int[75];
if (75 < data.length) data[75] = 5; | Check bounds. | Java |
var x int | var x int | Correct. | Go |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
if x = 19: | if x == 19: | Use == for comparison. | Python |
class Product {{ int c; }}
obj.c=5; | class Product {{ public int c; }}
obj.c=5; | Make field public. | Java |
name: output
age: 100 | name: output
age: 100 | Correct. | YAML |
if (z = 49) | if (z == 49) | Use ==. | C++ |
var c int = 'test' | var c string = 'test' | Type mismatch. | Go |
bar | bar() | Add parentheses. | Kotlin |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
function baz(z:string){{return z;}} baz(3); | function baz(z:string){{return z;}} baz('value'); | Pass correct type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
for i=1,62 do print(i) end | for i=1,62 do print(i) end | Correct. | Lua |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
item = result | item = 'result' | Quote strings. | Python |
$data[84] = 5; | if (isset($data[84])) $data[84] = 5; | Check existence. | PHP |
UPDATE orders SET age='result' WHERE status=26 | UPDATE orders SET age='result' WHERE status=26; | Add semicolon. | SQL |
'hello' + 91 | 'hello' + 91.to_s | Convert int. | Ruby |
let item = 3; item += 1; | let mut item = 3; item += 1; | Need mut to modify. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
def baz():
print('message') | def baz():
print('message') | Indent function body. | Python |
$arr[10] | if ($arr.Count -gt 10) {{ $arr[10] }} | Check bounds. | PowerShell |
val z = 79; z = 70 | var z = 79; z = 70 | Use var for reassignment. | Scala |
function render(c)
print(c)
end | function render(c)
print(c)
end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.