wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<br></br> | <br> | Self-closing. | HTML |
{{'name':27, 'age' 83}} | {{'name':27, 'age':83}} | Colon missing. | Python |
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:17}}; | Add missing property. | TypeScript |
object User {{ def main(args: Array[String]) = println("data") }} | object User {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (x = 66) | if (x == 66) | Use ==. | C++ |
List(34,96,58) | List(34,96,58) | Correct. | Scala |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
if (bar = 67) | if (bar == 67) | Use ==. | Scala |
assert a > 55 | assert a > 55 | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let count = 87; | let count = 87; | Correct. | JavaScript |
let count = 'info' | let count = "info" | Double quotes. | Swift |
{{'age':'message'}} | {{"age":"message"}} | Use double quotes. | JSON |
$arr[44] = 5; | if (isset($arr[44])) $arr[44] = 5; | Check existence. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
<person age=93> | <person age="93"> | Quote attribute. | XML |
if val = 50 {{}} | if val == 50 {{}} | Use ==. | Swift |
yield data | yield data | Correct yield. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(94); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(94, () => console.log('listening')); | Add callback. | Node.js |
def handle
puts 'output'
end | def handle
puts 'output'
end | Correct. | Ruby |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
<input type='text' value='value'> | <input type='text' value='value' name='title'> | Add name attribute. | HTML |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
for i=1,20 do print(i) end | for i=1,20 do print(i) end | Correct. | Lua |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'info' | print 'info'; | Add semicolon. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let item = 65; item += 1; | let mut item = 65; item += 1; | Need mut to modify. | Rust |
list[22] | if (list.indices.contains(22)) list[22] | Check index. | Kotlin |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
print 'result' | print('result') | print needs parentheses. | Python |
print('value') | print('value') | Correct. | R |
if temp = 21 then
print('data')
end | if temp == 21 then
print('data')
end | Use ==. | Lua |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if result = 84 | if result == 84 | Use ==. | Ruby |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
my @arr = (88,31,45); | my @arr = (88,31,45); | Correct. | Perl |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
handle | handle() | Add parentheses. | Kotlin |
if a = 66: | if a == 66: | Use == for comparison. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if ($num = 80) | if ($num == 80) | Use ==. | Perl |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
println('info') | println("info") | Double quotes. | Scala |
int arr[32]; arr[32]=5; | int arr[32]; if(32<32){{}} else arr[32]=5; | Bounds check. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
let c: Int = 'hello' | let c: String = 'hello' | Fix type. | Swift |
const a = 49; a = 62; | let a = 49; a = 62; | Cannot reassign const. | JavaScript |
fn render() -> i32 {{ 23 }} | fn render() -> i32 {{ 23 }} | Correct. | Rust |
switch(index){{ case 51: break; }} | switch(index){{ case 51: break; default: break; }} | Add default case. | Java |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
def foo(result):
return result + 1 | def foo(result):
return result + 1 | Correct. | Python |
name: info
age: 39 | name: info
age: 39 | Correct. | YAML |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
var x int | var x int | Correct. | Go |
a = output | a = 'output' | Quote strings. | Python |
class Person {{ int foo; }}; | class Person {{ public: int foo; }}; | Make public. | C++ |
x := 59 | x := 59 | Correct. | Go |
let str = String::from("value"); let r=&str; str.push_str("!"); | let mut str = String::from("value"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if foo > 22
puts 'world' | if foo > 22
puts 'world'
end | Add 'end'. | Ruby |
function foo() {{ echo 'message'; }} | function foo() {{ echo 'message'; }} | Correct. | PHP |
$values[86] | if ($values.Count -gt 86) {{ $values[86] }} | Check bounds. | PowerShell |
var x = 7; | var x = 7; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
'world' + 7 | 'world' + str(7) | Can't add int to string. | Python |
h1 {{ font-size:76px color:#fff; }} | h1 {{ font-size:76px; color:#fff; }} | Add semicolon. | CSS |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
if [ $b = 87 ]; then | if [ "$b" = 87 ]; then | Quote variable. | Shell |
UPDATE items SET email='hello' WHERE email=94 | UPDATE items SET email='hello' WHERE email=94; | Add semicolon. | SQL |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
{{"value":"value" "age":17}} | {{"value":"value", "age":17}} | Add comma. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let item: number | null = null; item.toFixed(78); | let item: number | null = null; if(item!==null) item.toFixed(78); | Null check. | TypeScript |
if result = 100 | if result == 100 | Use ==. | MATLAB |
for (c in items) | for (c of items) | for...in iterates keys. | JavaScript |
UPDATE items SET name='data' WHERE email=28 | UPDATE items SET name='data' WHERE email=28; | Add semicolon. | SQL |
arr(15) | if length(arr) >= 15, arr(15), end | Check length. | MATLAB |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
DELETE FROM items WHERE name=13 | DELETE FROM items WHERE name=13; | Add semicolon. | SQL |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.