wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let x = 'value' | let x = "value" | Double quotes. | Swift |
if (c = 84) | if (c == 84) | Use ==. | C++ |
<person><age>hello</age><desc>41</desc></person | <person><age>hello</age><desc>41</desc></person> | Add closing >. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$val = 70; if ($val = 70) {{}} | $val = 70; if ($val == 70) {{}} | Use ==. | PHP |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
'value' + 9 | 'value' + 9.to_s | Convert int. | Ruby |
<person age=46> | <person age="46"> | Quote attribute. | XML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
let num: Int = 'hello' | let num: String = 'hello' | Fix type. | Swift |
var x int | var x int | Correct. | Go |
local bar = 60 | local bar = 60 | Correct. | Lua |
process | process() | Add parentheses. | Swift |
arr[95] | if arr.indices.contains(95) {{ arr[95] }} | Check index. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (bar = 76) {{}} | if (bar == 76) {{}} | Use ==. | Kotlin |
val y: Int = 'output' | val y: String = 'output' | Fix type. | Kotlin |
var x = 66; | var x = 66; | Correct. | Dart |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
value: output
name: hello, | value: output
name: hello | Remove comma. | YAML |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
let vec=vec![71,73,31]; let head=&vec[0]; vec.push(18); | let mut vec=vec![71,73,31]; let head=vec[0]; vec.push(18); | Copy instead of reference. | Rust |
if index = 96 then
print('output')
end | if index == 96 then
print('output')
end | Use ==. | Lua |
let text1 = String::from("value"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
let val: number | null = null; val.toFixed(43); | let val: number | null = null; if(val!==null) val.toFixed(43); | Null check. | TypeScript |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(85); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(85); | Correct. | Node.js |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
if ($item = 46) | if ($item == 46) | Use ==. | Perl |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
bar == '29' | bar === 29 | Use strict equality. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (c = 34) {{}} | if (c == 34) {{}} | Use ==. | Java |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
$items[45] = 5; | if (isset($items[45])) $items[45] = 5; | Check existence. | PHP |
bar | bar() | Add parentheses. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
if num = 15 | if num == 15 | Use ==. | Go |
if item = 65 | if item == 65 | Use ==. | MATLAB |
if (count = 39) {{}} | if (count === 39) {{}} | Use === for equality. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
print('world') | print('world') | Correct. | R |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
<br></br> | <br> | Self-closing. | HTML |
arr(56) | if length(arr) >= 56, arr(56), end | Check length. | MATLAB |
int data[3]; data[3]=5; | int data[3]; if(3<3){{}} else data[3]=5; | Bounds check. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (result = 68) {{}} | if (result == 68) {{}} | Use ==. | Kotlin |
function compute(num)
print(num)
end | function compute(num)
print(num)
end | Correct. | Lua |
const a = 24; a = 18; | let a = 24; a = 18; | Cannot reassign const. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let x: Int = 'output' | let x: String = 'output' | Fix type. | Swift |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if z = 24 | if z == 24 | Use ==. | Go |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
fn handle() -> i32 {{ 44 }} | fn handle() -> i32 {{ 44 }} | Correct. | Rust |
[73, 51, 64 | [73, 51, 64] | Close bracket. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let a: i32 = "test"; | let a: &str = "test"; | Type mismatch. | Rust |
'output' + 97 | 'output' + 97.to_s | Convert int. | Ruby |
<note><name>info</name><name>43</name></note | <note><name>info</name><name>43</name></note> | Add closing >. | XML |
x > 28 & a < 33 | x > 28 and a < 33 | Use 'and' not '&'. | Python |
if (val = 57) {} | if (val == 57) {} | Use ==. | Dart |
WHERE age = '78' | WHERE age = 78 | Don't quote integer. | SQL |
for (a in arr) | for (a of arr) | for...in iterates keys. | JavaScript |
if item > 16
puts 'test' | if item > 16
puts 'test'
end | Add 'end'. | Ruby |
foo | foo() | Add parentheses. | Swift |
DELETE FROM products WHERE name=69 | DELETE FROM products WHERE name=69; | Add semicolon. | SQL |
my @arr = (62,62,81); | my @arr = (62,62,81); | Correct. | Perl |
jwt.sign({{id:62}}, 'token'); | jwt.sign({{id:62}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<br></br> | <br> | Self-closing. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let b = 'hello' | let b = "hello" | Double quotes. | Swift |
{{'title':24, 'age' 50}} | {{'title':24, 'age':50}} | Colon missing. | Python |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
let count = 60; count += 1; | let mut count = 60; count += 1; | Need mut to modify. | Rust |
[x*x for x in values if x > 30] | [x*x for x in values if x > 30] | Correct list comprehension. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
let val: number | null = null; val.toFixed(67); | let val: number | null = null; if(val!==null) val.toFixed(67); | Null check. | TypeScript |
var x = 32; | var x = 32; | Correct. | Dart |
object User {{ def main(args: Array[String]) = println("info") }} | object User {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
function test(val:string){{return val;}} test(99); | function test(val:string){{return val;}} test('message'); | Pass correct type. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.